Data Types and Variables

Quiz Guidelines

 

Multiple Choice Question

QID: 
286

Given the following code, which statements can be placed at the indicated position without causing compile and run time errors?

public class Test{
int i1;
static int i2;
public void method1(){
int i;       // ... insert statements here
}
}

Select 3 options

A. i = this.i1;
B. i = this.i2;
C. this = new Test( );
D. this.i = 4;
E. this.i1 = i2;

True or False

QID: 
285

The following code snippet will print 4.

int i1 = 1, i2 = 2, i3 = 3;
int i4 = i1 + (i2=i3 );
System.out.println(i4);

Select 1 option

A. True
B. False

Multiple Choice Question

QID: 
284

Which of these are not legal declarations within a class?

Select 1 option

A. static volatile int sa ;
B. final Object[ ] objArr = { null } ;
C. abstract int t ;
D. native void format( ) ;
E. final transient static private double PI = 3.14159265358979323846;

Multiple Choice Question

QID: 
283

What will the following program print?

public class TestClass{
static String str;
public static void main(String[] args){
System.out.println(str);
}
}

Select 1 option

A. It will not compile.
B. It will compile but throw an exception at runtime.
C. It will print 'null' (without quotes).
D. It will print nothing.
E. None of the above.

Multiple Choice Question

QID: 
282

An instance member ...

Select 2 options

A. can be a variable, a constant or a method.
B. is a variable or a constant.
C. belongs to the class.
D. belongs to an instance of the class.
E. is same as a local variable.

Pages