Get Latest Job Updates

Get Latest Walkins and Job Updates Directly to your Inbox.
20,000 People Subscribed

Sign Up Now.
Email address
Secure and Spam free...

Java Quiz-2

Java Quiz-2

Welcome to your Java Quiz-2

NameEmail
class A
{
A( ) { }
}

class B extends A
{ }

Which statement is true?
Which of the following class level (nonlocal) variable declarations will not compile?
What will be the output of the program?
int i = 0;
while(1)
{
if(i == 4)
{
break;
}
++i;
}
System.out.println("i = " + i);
What will be the output of the program?

int i = 0, j = 5;
tp: for (;;)
{
i++;
for (;;)
{
if(i > --j)
{
break tp;
}
}
System.out.println("i =" + i + ", j = " + j);
Which statement is true?
class Test1
{
public int value;
public int hashCode() { return 42; }
}
class Test2
{
public int value;
public int hashcode() { return (int)(value^5); }
}
which statement is true?
class Bar { }
class Test
{
Bar doBar()
{
Bar b = new Bar(); /* Line 6 */
return b; /* Line 7 */
}
public static void main (String args[])
{
Test t = new Test(); /* Line 11 */
Bar newBar = t.doBar(); /* Line 12 */
System.out.println("newBar");
newBar = new Bar(); /* Line 14 */
System.out.println("finishing"); /* Line 15 */
}
}
At what point is the Bar object, created on line 6, eligible for garbage collection?
class Test
{
private Demo d;
void start()
{
d = new Demo();
this.takeDemo(d); /* Line 7 */
} /* Line 8 */
void takeDemo(Demo demo)
{
demo = null;
demo = new Demo();
}
}
When is the Demo object eligible for garbage collection?
public class Test
{
public void foo()
{
assert false; /* Line 5 */
assert false; /* Line 6 */
}
public void bar()
{
while(true)
{
assert false; /* Line 12 */
}
assert false; /* Line 14 */
}
}
What causes compilation to fail?
What will be the output of the program?
String a = "newspaper";
a = a.substring(5,7);
char b = a.charAt(1);
a = a + b;
System.out.println(a);

Leaderboard for Java Quiz-2

1. srilatha-45 Points
2. sabeena-25 Points
3. jithendra-20 Points
4. SowjanyaPaloju-20 Points
5. ramya-15 Points