Submitted by c-admin on Wed, 05/29/2019 - 23:40
Which of the following are correct ways to initialize the static variables MAX and CLASS_GUID?
class Widget{
static int MAX; //1
static final String CLASS_GUID; // 2
Widget(){ //3
}
Widget(int k){ //4
}
}
Select 2 options
A. Modify lines //1 and //2 as : static int MAX = 111; static final String
CLASS_GUID = "XYZ123";
B. Add the following line just after //2 : static { MAX = 111; CLASS_GUID =
"XYZ123"; }
C. Add the following line just before //1 : { MAX = 111; CLASS_GUID =
"XYZ123"; }
D. Add the following line at //3 as well as //4 : MAX = 111; CLASS_GUID =
"XYZ123";
E. Only option 3 is valid.
Submitted by c-admin on Wed, 05/29/2019 - 23:36
Given that TestClass is a class, how many objects and reference variables are created by the following code?
TestClass t1, t2, t3, t4;
t1 = t2 = new TestClass();
t3 = new TestClass();
Select 1 option
A. 2 objects, 3 references.
B. 2 objects, 4 references.
C. 3 objects, 2 references.
D. 2 objects, 2 references.
E. None of the above
Submitted by c-admin on Wed, 05/29/2019 - 23:34
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.
Submitted by c-admin on Wed, 05/29/2019 - 23:26
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;
Submitted by c-admin on Wed, 05/29/2019 - 23:25
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; }
Pages