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 of code will give better performance? 1. a | 4 + c >> b & 7; 2. (a | ((( 4 * c ) >> b ) & 7 ))
1 will give better performance as it has no parentheses. | 2 will give better performance as it has parentheses. |
Both 1 & 2 will give equal performance. | Dependent on the computer system. |
What is the output of this program?
class box {
int width;
int height;
int length;
int volume;
void finalize() {
volume = width*height*length;
System.out.println(volume);
}
protected void volume() {
volume = width*height*length;
System.out.println(volume);
}
}
class Output {
public static void main(String args[])
{
box obj = new box();
obj.volume();
}
}
150 | 200 |
Runtime error | Compilation error |
Which of the following is a valid declaration of an object of class Box?
Box obj = new Box(); | Box obj = new Box; |
obj = new Box(); | new Box obj; |
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 |
What is the output of this program?
class exception_handling {
public static void main(String args[]) {
try {
int a[] = {1, 2,3 , 4, 5};
for (int i = 0; i < 7; ++i)
System.out.print(a[i]);
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.print("0");
}
}
}
12345 | 123450 |
1234500 | Compilation Error |
What is the name of the thread in output of this program?
class multithreaded_programing {
public static void main(String args[]) {
Thread t = Thread.currentThread();
System.out.println(t.isAlive());
}
}
0 | 1 |
true | false |
What is the output of this program?
class operators {
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
int var3;
var3 = ++ var2 * var1 / var2 + var2;
System.out.print(var2);
}
}
10 | 11 |
12 | 56 |
What is the stored in the object obj in following lines of code? box obj;
Memory address of allocated memory of object. | NULL |
Any arbitrary pointer | Garbage |
Which of the following contain error? (A) int x[] = int[10]; (B) int[] y = new int[5]; (C) float d[] =
(A) | (B) |
(A) & (C) | (B) & (C) |
Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?
transient | volatile |
global | No modifier is needed |
Finish Test
No comments :
Post a Comment