Exam
Exam
Technical Exam
Date: 16/10/2022
===================================================================================
=============================
1) If you compile and execute an application with the following code in its main()
method:
a) It will not compile because the String class does not support the = =
operator.
b) It will compile and run, but nothing is printed.
c) "Equal A" is the only thing that is printed.
d) "Equal B" is the only thing that is printed.
e) Both "Equal A" and "Equal B" are printed.
Answer : _____a_________________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
2) If you want a member variable to not be accessible outside the current class at
all,
what keyword should precede the name of the variable when declaring it?
Answer : ________private______________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
3) Consider the below snippet
int a = 5;
System.out.println(cube(a));
}
Answer:___a________________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++
4) Given the variables defined below:
int one = 1;
int two = 2;
char initial = '2';
boolean flag = true;
Answer:___a______________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
5) If val = 1 in the code below:
switch(val) {
case 2:
switch(val) {
case 2:
a) P
b) Q
c) R
d) S
e) PQRS
f) PQ
Answer:_____e___________________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
7) Assume that Sub1 and Sub2 are both subclasses of class Super.
Which statement best describes the result of attempting to compile and execute
the following statement:
sup = sub1;
Answer:____c___________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
8) For the following code:
class Super {
int index = 5;
System.out.println( "Super" );
}
}
int index = 2;
System.out.println( "Sub" );
}
}
public class Test {
Answer : _____e_______________________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++
9) If s1 is declared as:
String s1 = "phenobarbital";
String s2 = s1.substring( 3, 5 );
a) null
b) "eno"
c) "enoba"
d) "no"
Answer:____d_______________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
10) You want to limit access to a method of a public class to members of the same
class.Which access accomplishes this objective?
A. public
B. private
C. protected
D. transient
E. default access
Answer:________c_____________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
11) What is the numerical range of a char?
A. 0 ... 32767
B. 0 ... 65535
C. –256 ... 255
Answer:_________b____________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
12) Conside the Below Code
public class X {
byte b = 127;
byte c = 126;
byte d = b + c;
}
}
Answer:_________a_____
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
13) Purpose of Wrapper Classes in Java ?
Answer:__________object creation________________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++
14) Brief about Widening Typecasting and narrowing Typecasting ?
Answer:__________________________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++
15) What is parent class for every Java Class ?
Answer:___________object class________________
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++
16) Tell me Memory locations in JVM for below Members
a) 10
b) 11
c) 12
d) 9
Answer:_______b_______
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++