Test : Java_7
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
What will be the output of the program?
public class Test { public static void main(String[] args) { int x = 0; assert (x > 0) ? "assertion failed" : "assertion passed" ; System.out.println("finished"); } }
finished | Compiliation fails. |
An AssertionError is thrown and finished is output. | An AssertionError is thrown with the message "assertion failed." |
Which of these method is used to tell the calling thread to give up monitor and go to sleep until some other thread enters the same monitor?
wait() | notify() |
notifyAll() | sleep() |
Which of these keywords is used to refer to member of base class from a sub class?
upper | super |
this | None of the mentioned |
Which of these method of Thread class is used to Suspend a thread for a period of time?
terminate() | suspend() |
stop() | sleep() |
Which of these is true about unmodifiableCollection() method?
unmodifiableCollection() returns a collection that cannot be modified. | unmodifiableCollection() method is available only for List and Set. |
unmodifiableCollection() is defined in Collection class. | None of the mentioned. |
What is the length of the application box made by this program?
import java.awt.*; import java.applet.*; public class myapplet extends Applet { public void paint(Graphics g) { g.drawString("A Simple Applet", 20, 20); } }
20 | 50 |
100 | System Dependent |
Suppose that s1 and s2 are two strings. Which of the statements or expressions are valid?
(A) String s3 = s1 + s2;
(B) String s3 = s1 - s2;
(C) s1 <= s2
(D) s1.compareTo(s2);
(E) int m = s1.length();
(A), (C) & (E) | (D) & (E) |
(C), (D) & (E) | (A), (D) & (E) |
toRadian() and toDegree() methods were added by which version of Java?
Java 1.0 | Java 1.5 |
Java 2.0 | Java 3.0 |
A class member declared protected becomes member of subclass of which type?
public member | private member |
protected member | static member |
What is the output of this program?
class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"My Thread"); t.start(); } public void run() { System.out.println(t); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }
My Thread | Thread[My Thread,5,main] |
Compilation Error | Runtime Error |
Finish Test
No comments: