A variable defined within a block is visible.

Loading

Practice Language Fundamentals –

A variable defined within a block is visible.

What will be the output of the program?


			  		

Loading

Practice Language Fundamentals –

What will be the output of the program?

class Equals  {     
public static void main(String [] args) {
int x = 100;
double y = 100.1;
boolean b = (x = y); /* Line 7 */
System.out.println(b);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

public class ExamQuestion6 {     
static int x;
boolean catch() {
x++;
return true;
}
public static void main(String[] args) {
x=0;
if ((catch() | catch()) || catch())
x++;
System.out.println(x);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

public class ObjComp {     
public static void main(String [] args ) {
int result = 0;
ObjComp oc = new ObjComp();
Object o = oc;
if (o == oc)
result = 1;
if (o != oc)
result = result + 10;
if (o.equals(oc) )
result = result + 100;
if (oc.equals(o) )
result = result + 1000;
System.out.println("result = " + result);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

int I = 0; 
label: if (I < 2) {
System.out.print("I is " + I);
I++;
continue label;
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

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);

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

int x = 3;  
int y = 1;
if (x = y) /* Line 3 */ {
System.out.println("x =" + x);
}

 

What would be the output of the following program ?

Loading

Practice Operators and Assignments –

What would be the output of the following program ?

class test {
public static void main(String[] args) {
for(int i=0;i<=args.length;i++);
System.out.println(args[i]);
}
}

 

Which of the following two entities (reading from Left to Right) ca

Loading

Practice Operators and Assignments –

Which of the following two entities (reading from Left to Right) can be connected by the dot operator?

Which one creates an instance of an array?

Loading

Practice Declarations and Access Control –

Which one creates an instance of an array?

Which cause a compiler error?

Loading

Practice Declarations and Access Control –

Which cause a compiler error?

Which three form part of correct array declarations?

  1. pub

Loading

Practice Declarations and Access Control –

Which three form part of correct array declarations?

  1. public int a [ ]
  2. static int [ ] a
  3. public [ ] int a
  4. private int a [3]
  5. private int [3] a [ ]
  6. public final int [ ] a

What will be the output of the program?


			  		

Loading

Practice Declarations and Access Control –

What will be the output of the program?

public class ArrayTest {     
public static void main(String[ ] args) {
float f1[ ], f2[ ];
f1 = new float[10];
f2 = f1;
System.out.println("f2[0] = " + f2[0]);
}
}