Data Types and Variables

Quiz Guidelines

 

Multiple Choice Question

QID: 
276

Given the following set of member declarations, which of the following is true?

int a;    //  (1) 
static int a;    //  (2)
int f( )   { return a; }    //  (3) 
static int f( ) { return a; }    //  (4)

Select 2 options 

A. Declarations (1) and (3) cannot occur in the same class definition. 
B. Declarations (2) and (4) cannot occur in the same class definition. 
C. Declarations (1) and (4) cannot occur in the same class definition. 
D. Declarations (2) and (3) cannot occur in the same class definition. 
E. Declarations (1) and (2) cannot occur in the same class definition. 

Multiple Choice Question

QID: 
275

Which of the following can be valid declarations of an integer variable?

Select 2 options

A. global int x = 10;
B. final int x = 10;
C. public Int x = 10;
D. Int x = 10;
E. static int x = 10;

Multiple Choice Question

QID: 
274

Which of the following statements can be inserted at // 1 to make the code compile without errors?

public class InitTest{
static int si = 10;
int i;
final boolean bool;   // 1
}

Select 1 option

A. instance { bool = true; }
B. InitTest() { si += 10; }
C. { si = 5; i = bool ? 1000 : 2000;}
D. { i = 1000; }
E. { bool = (si > 5); i = 1000; }

Multiple Choice Question

QID: 
100

In which of these variable declarations, will the variable remain uninitialized unless explicitly initialized?

Select 1 option

A. Declaration of an instance variable of type int.
B. Declaration of a static class variable of type float.
C. Declaration of a local variable of type float.
D. Declaration of a static class variable of class Object
E. Declaration of an instance variable of class Object.

Multiple Choice Question

QID: 
99

What will the following program print?

public class TestClass{
public static void main(String[] args){
unsigned byte b = 0;
b--;
System.out.println(b);
}
}

Select 1 option

A. 0
B. -1
C. 255
D. -128
E. It will not compile.

Pages