Test : Java_9
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 is the output of this program?
class access{ public int x; private int y; void cal(int a, int b){ x = a + 1; y = b; } void print() { system.out.println(" " + y); } } class access_specifier { public static void main(String args[]) { access obj = new access(); obj.cal(2, 3); System.out.println(obj.x); obj.print(); } }
2 3 | 3 3 |
Runtime Error | Compilation Error |
What will be the output of the program (when you run with the -ea option) ?
public class Test { public static void main(String[] args) { int x = 0; assert (x > 0) : "assertion failed"; /* Line 6 */ System.out.println("finished"); } }
finished | Compilation fails. |
An AssertionError is thrown. | An AssertionError is thrown and finished is output. |
What is the correct format of declaration of abstract class
class abstract clsName { // body of class } | abstract class clsName; { // body of class } |
abstract class clsName { // body of class } | None of the above |
By which method a class can be abstracted
Private | Public |
Protected | All of the above |
Which of these methods is used to compare a specific region inside a string with another specific region in another string?
regionMatch() | match() |
RegionMatches() | regionMatches() |
What is the output of this program?
class bool_operator { public static void main(String args[]) { boolean a = true; boolean b = !true; boolean c = a | b; boolean d = a & b; boolean e = d ? b : c; System.out.println(d + " " + e); } }
truefalse | falsetrue |
truetrue | falsefalse |
Which of these keywords must be used to handle the exception thrown by try block in some rational manner?
try | finally |
throw | catch |
Which of these keywords must be used to monitor for exceptions?
try | finally |
throw | catch |
Which of interface contains all the methods used for handling thread related operations in Java?
Runnable interface | ThreadHandling interface |
Math interface | System interface |
Which of the following classes are available in the java.lang package?
(A) Stack
(B) Object
(C) Math
(D) Random
(E) String
(F) StringBuffer
(G) Vector
(B), (C) & (E) | (B), (C), (E) & (F) |
(B), (E) & (F) | (A), (B), (C), (E) & (F) |
Finish Test
No comments: