0% found this document useful (0 votes)
6 views

JavaTest 01 With Answers

1. Java compiles to bytecode. 2. The command to run a compiled Java program is "java". 3. When comparing strings, "sb1==sb2" returns false but "sb1.equals(sb2)" returns true.

Uploaded by

shakir.hello
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

JavaTest 01 With Answers

1. Java compiles to bytecode. 2. The command to run a compiled Java program is "java". 3. When comparing strings, "sb1==sb2" returns false but "sb1.equals(sb2)" returns true.

Uploaded by

shakir.hello
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

DHI Java Surprise Test – 001 Duration: 1 hour

1. Java enables the creation of cross-platform programs by compiling into an intermediate


representation called Java ____________
a. Byte Code
b. Firewall
c. Tetra Code
d. View Code
2. Command to execute a compiled java programs is
a. run
b. execute
c. javac
d. java

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));
}
}

What is the result of attempting to compile and run the program?

a. Prints: false, true


b. Prints: false, false
c. Prints: true, false
d. Prints: true, true

8. A blueprint for a software object is called a :

a. Field
b. Method
c. Class
d. Package

9. The term "instance variable" is another name for

a. Static field
b. non-static field.
c. Local variable
d. None of the above

10. In Java, character strings are represented by:

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

12. A namespace that organizes classes and interfaces by functionality is called :

a. class
b. namespace
c. package
d. jar

13.
class A{
int size;

public A( int x){

this.size = x;

class B extends A{

int b1, b2;

public B(){

super(100);

b1 = 200; b2 = 300;

public static void main(String args[]) {

B objB = new B(); System.out.println(objB.size + objB.b1 + objB.b2);

}
DHI Java Surprise Test – 001 Duration: 1 hour

What will be the output?

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

Which of the following statements are true?


a. The compiler attempts to create a default constructor for
class A.
b. The compiler attempts to create a default constructor for
class B.
c. Compile-time error at 1.
d. Compile-time error at 2.

You might also like