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-1

Java Quiz-1

Welcome to your Java Quiz-1

NameEmail

  1. Which two statements are equivalent?


1. 3/2
2. 3<2
3. 3*4
4. 3<<2
2. What will be the output of the program?
Float f = new Float("12");
switch (f)
{
case 12: System.out.println("Twelve");
case 0: System.out.println("Zero");
default: System.out.println("Default");
}
3. What will be the output of the program?
class SC2
{
public static void main(String [] args)
{
SC2 s = new SC2();
s.start();
}

void start()
{
int a = 3;
int b = 4;
System.out.print(" " + 7 + 2 + " ");
System.out.print(a + b);
System.out.print(" " + a + b + " ");
System.out.print(foo() + a + b + " ");
System.out.println(a + b + foo());
}

String foo()
{
return "foo";
}
}
4. What will be the output of the program?
Float f = new Float("12");
switch (f)
{
case 12: System.out.println("Twelve");
case 0: System.out.println("Zero");
default: System.out.println("Default");
}
5. Which statement is true for the class java.util.ArrayList?
6. class X implements Runnable
{
public static void main(String args[])
{
/* Missing code? */
}
public void run() {}
}

Which of the following line of code is suitable to start a thread ?
7.

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?
8. Which of the following statements is true?
9. What will be the output of the program (in jdk1.6 or above)?
public class BoolTest
{
public static void main(String [] args)
{
Boolean b1 = new Boolean("false");
boolean b2;
b2 = b1.booleanValue();
if (!b2)
{
b2 = true;
System.out.print("x ");
}
if (b1 & b2) /* Line 13 */
{
System.out.print("y ");
}
System.out.println("z");
}
}
10.

public void foo( boolean a, boolean b)
{
if( a )
{
System.out.println("A"); /* Line 5 */
}
else if(a && b) /* Line 7 */
{
System.out.println( "A && B");
}
else /* Line 11 */
{
if ( !b )
{
System.out.println( "notB") ;
}
else
{
System.out.println( "ELSE" ) ;
}
}
}

Leaderboard for Java Quiz-1

1. srilatha-45 Points
2. jithendra-40 Points
3. jithendra-40 Points
4. ramya-40 Points
5. -40 Points