JavaTest 01 With Answers
JavaTest 01 With Answers
3. class MWC202 {
public static void main (String[] args) {
String sb1 = new String("ABC");
String sb2 = new String("ABC");
System.out.print((sb1==sb2)+","+sb1.equals(sb2));
}
}
a. Field
b. Method
c. Class
d. Package
a. Static field
b. non-static field.
c. Local variable
d. None of the above
a. Java.lang.String
DHI Java Surprise Test – 001 Duration: 1 hour
b. string
c. char[]
d. None of the above
11. Hiding internal data from the outside world, and accessing it only through publicly
exposed methods is known as :
a. Aggregation
b. Data Encapsulation
c. Polymorphism
d. Inheritance
a. class
b. namespace
c. package
d. jar
13.
class A{
int size;
this.size = x;
class B extends A{
public B(){
super(100);
b1 = 200; b2 = 300;
}
DHI Java Surprise Test – 001 Duration: 1 hour
a. 500
b. 600
c. 100200300
d. Compile time error
14. Which of these lists contains at least one word that is not a Java keyword?
a. abstract, default, if, private, this
b. do, implements, protected, boolean, throw
c. import, break, double, exception, throws
d. byte, else, return, transient
e. None of the above
15. class A {
A(int i) {} // 1
}
class B extends A {} // 2