Test : Java_10
This test contains 10 questions based on Java.
Each question answered correctly awards you 1 point and each incorrect answer has a penalty of -0.25 points, no points are deducted for unattempted answers.
Each question answered correctly awards you 1 point and each incorrect answer has a penalty of -0.25 points, no points are deducted for unattempted answers.
Select Test Type
You Get +1 for each correct answer and -0.25 for each incorrect answer
Time Left - minutes :seconds
Which of the following statements are false in the concept of abstract classes:
| Can b instantiated | It may or may not include abstract methods |
| It can be subclassed | None of the above |
Which of these is static variable defined in Collections?
| EMPTY_SET | EMPTY_LIST |
| EMPTY_MAP | All of the mentioned |
Which of the following statements are incorrect?
| private members of class can only be accessed by other members of the class | private members of class can be inherited by a sub class, and become protected members in sub class |
| protected members of a class can be inherited by a sub class, and become private members of the sub class | public members of class can be accessed by any code in the program |
What is the output of this program?
import java.util.*;
class Bitset {
public static void main(String args[]) {
BitSet obj = new BitSet(5);
for (int i = 0; i < 5; ++i)
obj.set(i);
obj.clear(2);
System.out.print(obj);
}
}| {0, 1, 3, 4} | {0, 1, 2, 4} |
| {0, 1, 2, 3, 4} | {0, 0, 0, 3, 4} |
what will be the output
int a=2;
System.out.println(a<<2);
| 0 | 8 |
| 6 | none of these |
Which of these is used as default for a member of a class if no access specifier is used for it?
| private | public |
| public, within its own package | protected |
Which of these is not a correct statement?
| Every class containing abstract method must be declared abstract. | Abstract class defines only the structure of the class not its implementation. |
| Abstract class can be initiated by new operator. | Abstract class can be inherited. |
Which of the following statements are incorrect?
| String is a class. | Strings in java are mutable |
| Every string is an object of class String. | Java defines a peer class of String, called StringBuffer, which allows string to be altered |
What is the output of this program?
class output {
public static void main(String args[])
{
char ch;
ch = "hello".charAt(1);
System.out.println(ch);
}
}| h | e |
| l | o |
Difference between == and equals method?
| both behaves same | == compares the references whereas equals compares the contents |
| == compares the contents whereas equals compares the references | None of the above |
Finish Test
No comments: