You are on page 1of 7

1.

Reason for Java language is platform independent


a) write anywhere, run once
b) write once, run anywhere
c) write once, run once
d) write twice run once

Answer: b

2. Static Polymorphism in Java can be achieved by using _______


a) Method overriding
b) Method abstraction
c) Method overloading
d) Both method over loading & method overriding

Answer: c

3. What is the output of following program?

class Base {
private static void display() {
System.out.println("Static or class method from Base");
}
}
class Derived extends Base {
private static void display() {
System.out.println("Static or class method from Derived");
}
}

public class Test {


public static void main(String args[])
{
Base obj= new Derived();
obj.display();
}
}

a) Static or class method from Derived


b) Compile Time Error
c) Static or class method from Base
d) Run Time Error

Answer: b
4. What is Abstraction in OOP Language?
a) binding member functions and data members within the object
b) acquiring data members and member functions from Parent class
c) Controlling the accessibility of data members within the class
d) Controlling the accessibility of data members as well as member functions
within the class

Answer: d

5. What is the output of the following program?

public class Test {

public static void main(String[] args) {


String str1= new String("ABCD");
String str2= new String("ABCD");
if(str1 == str2)
{
System.out.println("Right");
}
}

a) Right
b) ABCD
c) Compile Time Error
d) Nothing will be Printed

Answer: d

6. What is the output of following program?

class Car {
public void run()
{
System.out.println("Car is running");
}
}

public class Audi extends Car {


public void run()
{
System.out.println("Audi is running");
}
public static void main(String args[]) {
Car b = new Audi();
b.run();
}
}

a) Audi is running
b) Car is running
c) Car is running Audi is running
d) Nothing will be printed

Answer: a

7. equals( ) & hashcode( ) are part of which class in Java?

a) Exception class
b) Thread class
c) HashMap class
d) Object class

Answer: d

8. As per Inheritance concept in Java which of the following statement is correct?

a) Multi-Level and Multiple inheritance is only possible


b) Multiple inheritance possible
c) Multi-Level inheritance is possible
d) Only Single-Level is possible

Answer: c

9. What is the output of following program?

public class Company {

public static void main(String args[]) {


Set cities = new HashSet();
cities.add("Delhi");
cities.add("Mumbai");
cities.add("Delhi");
cities.add("Mumbai");

Iterator<String> itr = cities.iterator();


while (itr.hasNext()) {
System.out.println(itr.next());
}

}
}

a) Mumbai Delhi Mumbai Delhi


b) Mumbai Delhi
c) Delhi Mumbai
d) Delhi Mumbai Delhi Mumbai

Answer: c

10. Generics in Java provide which of the following features?

a) Collection handling
b) Threading
c) Exception Handling
d) Type Safety

Answer: d

11. In JVM, Garbage Collector is used for

a) Memory Allocation for newly objects created


b) Cleaning of the un-referenced objects
c) Holding Static Values
d) Removing the referenced objects

Answer: b

12. What is the output of the following program?

class MyThread implements Runnable{

public void run() {


for(int i=0;i<10;i++) {
if(i%2==0) {
System.out.println(i);
}
}
}
}

public class Test{


public static void main(String[] args) {
MyThread myThread = new MyThread();
Thread t = new Thread(myThread);
t.start();
}
}

a) 0123456789
b) 02468
c) Nothing will be printed
d) 13579

Answer: b

13. Which characteristics of Interface in Java holds true in the following?

a) Only the data members are public by default


b) Only the member functions are public by default
c) By default all data members and member functions are public
d) None of the above

Answer: c

14. Which of the access modifiers are valid in Java?

a) Public, Protected and Private


b) Public, Default, Protected and Private
c) Public and Private
d) Public, Void, Private

Answer: b

15. Which of following command set fall under DDL in Database?

a) Create, Drop, Alter


b) Create, Insert, Update
c) Delete, Insert, Update
d) Alter, Delete, Update

Answer: a

16. What is the output of following program?

public class Test{


public static void main(String[] args) {
String your_name = "Delhi";
String my_name = new String("Delhi");
System.out.println(your_name==my_name);
System.out.println(your_name.equals(my_name));

}
}

a) True True
b) True False
c) False True
d) False False

Answer: c

17. Multi-Threading provides which following feature in Java?

a) Parallelism
b) Serialization
c) Complex Task Execution
d) None of the above

Answer: a

18. Which data type in Java is immutable?

a) Char
b) Integer
c) Double
d) String
e) Float

Answer: d

19. What is SDLC?


a) Software Design Life Cycle
b) Software Development Life Cycle
c) Software Deployment Life Cycle

Answer: b

20. What are linear data structures & non-linear data structures?
a) Linear – Trees, Queues, Stacks, Arrays & Non-Linear – Linked Lists, Graphs
b) Linear – Arrays, Queues, Stacks, Linked Lists & Non-Linear – Trees, Graphs
c) Linear – Arrays, Stacks, Linked Lists & Non-Linear – Queues, Trees, Graphs
d) Linear – Arrays, Queues, Linked Lists & Non-Linear – Stacks, Trees, Graphs
Answer: b

You might also like