Test : Java 11
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 keyword is used by method to refer to the object that invoked it?
import | catch |
abstract | this |
The methods wait() and notify() are defined in
java.lang.String | java.lang.Runnable |
java.lang.Thread | java.lang.Object |
Which of these keywords is used to refer to member of base class from a sub class?
upper | super |
this | None of the mentioned |
What is the output of this program?
class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); t.setName("New Thread"); System.out.println(t); } }
Thread[5,main] | Thread[New Thread,5] |
Thread[New Thread,5,main] | Thread[main,5,main] |
What is the output of this program?
class newthread extends Thread { Thread t; String name; newthread(String threadname) { name = threadname; t = new Thread(this,name); t.start(); } public void run() { } } class multithreaded_programing { public static void main(String args[]) { newthread obj1 = new newthread("one"); newthread obj2 = new newthread("two"); try { obj1.t.wait(); System.out.print(obj1.t.isAlive()); } catch(Exception e) { System.out.print("Main thread interrupted"); } } }
true | false |
Main thread interrupted | None of the mentioned |
public class Test
{
public void foo()
{
assert false; /* Line 5 */
assert false; /* Line 6 */
}
public void bar()
{
while(true)
{
assert false; /* Line 12 */
}
assert false; /* Line 14 */
}
}
What causes compilation to fail?
Line 5 | Line 6 |
Line 12 | Line 14 |
What is the output of relational operators?
Integer | Boolean |
Characters | Double |
What will be the output of the program?
public class Test { public static int y; public static void foo(int x) { System.out.print("foo "); y = x; } public static int bar(int z) { System.out.print("bar "); return y = z; } public static void main(String [] args ) { int t = 0; assert t > 0 : bar(7); assert t > 1 : foo(8); /* Line 18 */ System.out.println("done "); } }
bar | bar done |
foo done | Compilation fails |
What is the output of this program?
class box { int width; int height; int length; int volume; box() { width = 5; height = 5; length = 6; } void volume() { volume = width*height*length; } } class constructor_output { public static void main(String args[]) { box obj = new box(); obj.volume(); System.out.println(obj.volume); } } }
100 | 150 |
200 | 250 |
What is the output of this program?
class Relational_operator { public static void main(String args[]) { int var1 = 5; int var2 = 6; System.out.print(var1 > var2); } }
0 | 1 |
false | true |
Finish Test
No comments: