Test : Java_22
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 keywords is used to manually throw an exception?
| catch | finally |
| throw | try |
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;
}
}
class access_specifier {
public static void main(String args[])
{
access obj = new access();
obj.cal(2, 3);
System.out.println(obj.x + " " + obj.y);
}
}| 3 3 | 2 3 |
| Runtime Error | Compilation Error |
Given the code
String s = new String("abc");
Which of the following calls are valid?
(A) s.trim()
(B) s.replace('a', 'A')
(C) s.substring(3)
(D) s.toUppercase()
(E) s.setCharAt(1,'A')
(F) s.append("xyz")
| (A), (C), (D) & (E) | (A), (B) & (C) |
| (A), (B), (C) & (D) | (C), (D) & (E) |
Which of these statement is incorrect?
| Applets do not require a main() method at all. | Every class must contain a main() method. |
| There can be only one main() method in a program. | main() method must be made public. |
what will be the output
int i=20;
System.out.println(++i + ++i);
| 40 | 42 |
| 43 | 44 |
Which of interface contains all the methods used for handling thread related operations in Java?
| Runnable interface | ThreadHandling interface |
| Math interface | System interface |
What is the output of this program?
class static_out {
static int x;
static int y;
int add(int a, int b){
x = a + b;
y = x + b;
}
}
class static_use {
public static void main(String args[])
{
static_out obj1 = new static_out();
static_out obj2 = new static_out();
int a = 2;
obj1.add(a, a + 1);
obj2.add(5, a);
System.out.println(obj1.x + " " + obj2.y);
}
}| 7 7 | 6 7 |
| 7 9 | 9 7 |
Which of these methods deletes all the elements from invoking collection?
| clear() | reset() |
| delete() | refresh() |
Which of these access specifiers can be used for an interface?
| Public | Protected |
| private | All of the mentioned |
What is the output of this program?
class output {
public static void main(String args[])
{
String c = "Hello i love java";
boolean var;
var = c.startsWith("hello");
System.out.println(var);
}
}| true | false |
| 0 | 1 |
Finish Test
No comments: