JavaQuizzes

Quiz Guidelines

 

Multiple Choice Question

QID: 
512

Consider the following class :

public class Test{
public static void main(String[] args){
if (args[0].equals("open"))
if (args[1].equals("someone"))
System.out.println("Hello!");
else System.out.println("Go away "+ args[1]);
}
}

Which of the following statements are true if the above program is run with the command line : java Test closed

Select 1 option

A. It will throw ArrayIndexOutOfBoundsException at runtime.
B. It will end without exceptions and will print nothing.
C. It will print Go away
D. It will print Go away and then will throw ArrayIndexOutOfBoundsException.
E. None of the above.

Multiple Choice Question

QID: 
513

What will be the output of the following code snippet?

int a = 1;
int[] ia = new int[10];
int b = ia[a];
int c = b + a;
System.out.println(b = c);

Select 1 option

A. 0
B. 1
C. 2
D. true
E. false

Multiple Choice Question

QID: 
514

What will the following code print?

class Test{
public static void main(String[] args){
int k = 1;
int[] a = { 1 };
k += (k = 4) * (k + 2);
a[0] += (a[0] = 4) * (a[0] + 2);
System.out.println( k + " , " + a[0]);
}
}

Select 1 option

A. It will not compile.
B. 4 , 4
C. 25 , 25
D. 13 , 13
E. None of the above.

Multiple Choice Question

QID: 
515

Which of the following expressions will evaluate to true if preceded by the following code?

String a = "java";
char[] b = { 'j', 'a', 'v', 'a' };
String c = new String(b);
String d = a;

Select 3 options

A. (a == d)
B. (b == d)
C. (a == "java")
D. a.equals(c)

Multiple Choice Question

QID: 
516

What will the following program print?

public class TestClass{
static boolean b;
static int[] ia = new int[1];
static char ch;
static boolean[] ba = new boolean[1];
public static void main(String args[]) throws Exception{
boolean x = false;
if( b ){
x = ( ch == ia[ch]);
}
else x = ( ba[ch] = b );
System.out.println(x+" "+ba[ch]);
}
}

Select 1 option

A. true true
B. true false
C. false true
D. false false
E. It will not compile.

Pages

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!