Instruction
- Total number of questions : 30.
- Time alloted : 30 minutes.
- Each question carry 1 mark.
- No Negative marks
- DO NOT refresh the page.
- All the best :-).
1. |
Which of these literals can be contained in float data type variable? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: Range of float data type is -(3.4e38) To +(3.4e38) |
2. |
Which one is a valid declaration of a boolean? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Boolean can only be assigned true or false literals. |
3. |
Which of these can not be used for a variable name in Java? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: Keywords are specially reserved words which can not be used for naming a user defined variable, example : class, int, for etc. |
4. |
What is Truncation is Java? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: None. |
5. |
Which of these is necessary to specify at time of array initialization? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: None. |
6. |
Which of these statements are incorrect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: None. |
7. |
Which of these statements are incorrect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: The right shift operator automatically fills the higher order bit with its previous contents each time a shift occurs. This also preserves the sign of the value. |
8. |
Which of these statement is correct? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: true and false are keywords, they are non numeric values which do no relate to zero or non zero numbers. true and false are boolean values. |
9. |
Which of these statements are incorrect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Division operator, /, has equal precedence as of multiplication operator. In expression involving multiplication and division evaluation of expression will begin from right side when no brackets are used. |
10. |
Which of these statement is incorrect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: No two case constants in the same switch can have identical values. |
11. |
Which of these statement is incorrect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: Every class does not need to have a main() method, there can be only one main() method which is made public. |
12. |
Which of these statement is incorrect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: All object of class share a single copy of methods defined in a class, Methods are allotted memory only once. All the objects of the class have access to methods of that class are allotted memory only for the variables not for the methods. |
13. |
Which function is used to perform some action when the object is to be destroyed? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: None. |
14. |
What is the output of the following code? class San { public void m1 (int i,float f) { System.out.println(" int float method"); } public void m1(float f,int i); { System.out.println("float int method"); } public static void main(String[]args) { San s=new San(); s.m1(20,20); } } |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: While resolving overloaded method, compiler automatically promotes if exact match is not found. But in this case, which one to promote is an ambiguity. |
15. |
Which of the following statements are incorrect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: private members of a class can not be inherited by a sub class. |
16. |
Which of the following statements are incorrect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: None. |
17. |
Which of the following statements are incorrect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: Strings in Java are immutable that is they can not be modified. |
18. |
What is the output of this program? class A { public int i; protected int j; } class B extends A { int j; void display() { super.j = 3; System.out.println(i + " " + j); } } class Output { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } } |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: Both class A & B have member with same name that is j, member of class B will be called by default if no specifier is used. I contains 1 & j contains 2, printing 1 2. |
19. |
At line number 2 below, choose 3 valid data-type attributes/qualifiers among “final, static, native, public, private, abstract, protected” public interface Status { /* insert qualifier here */ int MY_VALUE = 10; } |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: Every interface variable is implicitly public static and final. |
20. |
Which of these keywords cannot be used for a class which has been declared final? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: A abstract class is incomplete by itself and relies upon its subclasses to provide complete implementation. If we declare a class final then no class can inherit that class, an abstract class needs its subclasses hence both final and abstract cannot be used for a same class. |
21. |
Which of these constructors is used to create an empty String object? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: None . |
22. |
Which of these methods can be used to convert all characters in a String into a character array? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: charAt() return one character only not array of character. |
23. |
Which of the following statement is correct? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: replace() method replaces all occurrences of one character in invoking string with another character. |
24. |
Which of the following statement is correct? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: reverse() method reverses all characters. It returns the reversed object on which it was called. |
25. |
Which of the following are incorrect form of StringBuffer class constructor? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: None. |
26. |
Which of these data type value is returned by equals() method of String class? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: equals() method of string class returns boolean value true if both the string are equal and false if they are unequal. |
27. |
Which of the following is correct way of importing an entire package ‘pkg’? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Operator * is used to import the entire package. |
28. |
Which of the following is correct way of implementing an interface salary by class manager? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: None. |
29. |
Which of the following is method of wrapper Float for converting the value of an object into byte? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: None. |
30. |
Which of the following is method of wrapper Integer for converting the value of an object into int? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: None. |