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 these lines will give an error line 1 :int a=1; line 2 :char c=25; line 3 :double d=2.9;
line 1 | line 2 |
line 3 | none of these |
Following code prints ?
- int a=5;
- System.out.println(a -= a+ = a -= a += a);
0 | 5 |
-5 | none of these |
If a class inheriting an abstract class does not define all of its function then it will be known as?
abstract | A simple class |
Static class | None of the mentioned |
What is the output of this program?
class A {
public int i;
private int j;
}
class B extends A {
void display() {
super.j = super.i + 1;
System.out.println(super.i + " " + super.j);
}
}
class inheritance {
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
2 2 | 2 3 |
Runtime Error | Compilation Error |
public class Test2
{
public static int x;
public static int foo(int y)
{
return y * 2;
}
public static void main(String [] args)
{
int z = 5;
assert z > 0; /* Line 11 */
assert z > 2: foo(z); /* Line 12 */
if ( z < 7 )
assert z > 4; /* Line 14 */
switch (z)
{
case 4: System.out.println("4 ");
case 5: System.out.println("5 ");
default: assert z < 10;
}
if ( z < 10 )
assert z > 4: z++; /* Line 22 */
System.out.println(z);
}
}
Line 11 | Line 12 |
Line 14 | Line 22 |
What is the biggest disadvantage of using inheritance
Can be implemented in point class | Pointers can't be used |
Multiple inheritance can't be used | None of the above |
Consider the following two classes:
public class ClassA {Which method hides a method in the superclass?
public void methodOne(int i) {
}
public void methodTwo(int i) {
}
public static void methodThree(int i) {
}
public static void methodFour(int i) {
}
}
public class ClassB extends ClassA {
public static void methodOne(int i) {
}
public void methodTwo(int i) {
}
public void methodThree(int i) {
}
public static void methodFour(int i) {
}
}
MethodOne | MethodTwo |
MethodThree | MethodFour |
What is the output of this program?
import java.util.*;
class stack {
public static void main(String args[]) {
Stack obj = new Stack();
obj.push(new Integer(3));
obj.push(new Integer(2));
obj.pop();
obj.push(new Integer(5));
System.out.println(obj);
}
}
[3, 5] | [3, 2] |
[3, 2, 5] | [3, 5, 2] |
Which of these can be used to fully abstract a class from its implementation?
Objects | Packages |
Interfaces | None of the Mentioned. |
what will be the output int i=10; System.out.println(i++ + ++i);
20 | 21 |
22 | 23 |
Finish Test
No comments :
Post a Comment