Test : Java_5
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 box { int width; int height; int length; } class mainclass { public static void main(String args[]) { box obj = new box(); obj.widht = 10; obj.height = 2; obj.length = 10; int y = obj.widht * obj.height * obj.length; System.out.print(y); } }
12 | 200 |
400 | 100 |
What will be the output of the following code:
public class Point extends Shape { static int x, y; public Point() { x = 0; y = 0; } public double area() { return 0; } public double perimeter() { return 0; } public static void print() { System.out.println("point: " + x + "," + y); } public static void main(String args[]) { Point p = new Point(); p.print(); } }
None | point: 0, 0 |
point: 1, 1 | point: 0, 1 |
Which of these method of String class can be used to test to strings for equality?
isequal() | isequals() |
equal() | equals() |
What is the output of this program?
class output { public static void main(String args[]) { String s1 = "Hello"; String s2 = new String(s1); String s3 = "HELLO"; System.out.println(s1.equals(s2) + " " + s2.equals(s3)); } }
true true | false false |
true false | false true |
Which of these lines will give an error
line 1. int a=1,b=2;
line 2. float c=2.0F;
line 3. System.out.println((a==c)+""+(c==b));
line 2 & line 3 | line 3 only |
line 2 only | none of these |
Which of these is an abstract class?
Thread | Runnable |
Multithread | System |
What is the output of this program?
class A { public int i; protected int j; } class B extends A { int j; void display() { super.j = 3; System.out.println(i + " " + j); } } class Output { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }
1 2 | 2 1 |
3 1 | 1 3 |
Which of these method of Thread class is used to suspend a thread for a period of time?
sleep() | terminate() |
suspend() | stop() |
What is the return type of Constructors?
int | float |
void | None of the mentioned |
What is the output of this program?
class area { int width; int length; int area; void area(int width, int length) { this.width = width; this.length = length; } } class Output { public static void main(String args[]) { area obj = new area(); obj.area(5 , 6); System.out.println(obj.length + " " + obj.width); } }
0 0 | 5 6 |
6 5 | 6 6 |
Finish Test
No comments: