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;
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 |
Which of these have highest precedence?
() | ++ |
* | >> |
What is the output of this program?
class operators {
public static void main(String args[])
{
int x = 8;
System.out.println(++x * 3 + " " + x);
}
}
24 8 | 25 9 |
27 4 | 27 9 |
Which of the following operators can operate on a boolean variable? 1. && 2. == 3. ?: 4. +=
3 & 2 | 1 & 4 |
1, 2 & 4 | 1, 2 & 3 |
Given the code String s1 = "yes"; String s2 = "yes"; String s3 = new String(s1); Which of the following would equate to true? (A) s1 == s2 (B) s1 = s2 (C) s3 == s1 (D) s1.equals(s2) (E) s3.equals(s1)
(A), (C) & (E) | (A), (B) & (C) |
(A), (D) & (E) | (D) & (E) |
Which of these lines will give an error line 1 :int a=1; line 2 :float f=2; line 3 :double d=2.9;
line 1 | line 2 |
line 3 | none of these |
What is the output of this program?
class equality {
int x;
int y;
boolean isequal() {
return(x == y);
}
}
class Output {
public static void main(String args[])
{
equality obj = new equality();
obj.x = 5;
obj.y = 5;
System.out.println(obj.isequal); }
}
True | False |
0 | 1 |
What is the output of this program?
class A {
int i;
void display() {
System.out.println(i);
}
}
class B extends A {
int j;
void display() {
System.out.println(j);
}
}
class method_overriding {
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
0 | 1 |
2 | Compilation Error |
What is the output of this program?
interface calculate {
int VAR = 0;
void cal(int item);
}
class display implements calculate {
int x;
void cal(int item) {
if (item < 2)
x = VAR;
else
x = item * item;
}
}
class interfaces {
public static void main(String args[]) {
display arr[] = new display[3];
arr[0].cal(0);
arr[1].cal(1);
arr[2].cal(2);
System.out.print(arr[0].x + " " + arr[1].x + " " + arr[2].x);
}
}
0 1 2 | 0 2 4 |
0 0 4 | 0 1 4 |
class A {
int i;
void display() {
System.out.println(i);
}
}
class B extends A {
int j;
void display() {
System.out.println(j);
}
}
class inheritance_demo {
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
0 | 1 |
2 | 3 |
Finish Test
Comments
Post a Comment