Java MCQ Questions with Answers
Very Important Questions for Diploma Students
1. Which of the following variable declaration would not compiled in a java program
Answer : D
Explanation : The syntax of variable in java is < datatype variablename; >
2. A constructor is related with
Answer : A
Explanation : Constructors are the member functions which are called automatically whenever an object is created. It is a mandatory functions to be called for an object to be created as this helps in initializing the object to a legal initial value for the class.
3. JVM is a
Answer : A
Explanation : JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.
4. What is byte code in context of Java
Answer : A
Explanation : Java use compiler and interpreter both where compiler translate java code into byte code and interpreter translate byte code into binray code.
5. The Java run time system automatically calls this method while garbage collection
Answer : B
Explanation : ‘finalize()’ method is automatically called by the java compiler before destroying the object to free any resources.
Java MCQ
6. An overloaded method consist of
Answer : A
Explanation : Overloading method to declear multiple function with same name but use different number of argument.
7. A protected member can be accessed in
Answer : A
Explanation : Protected data member and method are only accessible by the classes of the same package and the subclasses present in any package.
8. All exception types are sub classes of the built in class in
Answer : D
Explanation : All Exception types are subclasses of the built-in class Throwable. Exception is used for exceptional conditions that user program should catch.
9. In Java , objects are passed as
Answer : C
Explanation : Objects are passed by call by reference refers to passing the real reference of the variable in memory.
10. Which of following not a component of Java IDE
Answer : D
Explanation : An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development.
Java MCQ
11. Which of following is incorrect var-name
Answer : B
Explanation : Variable name always starts with letters.
12. Applet cann’t be viewed using
Answer : D
13. Java compiler Javac translate Java source code into
Answer : B
Explanation : The Java compiler (javac) converts the source code into bytecode.
14. In Java character const value is its integer value in the
Answer : C
15. Which one of the used to document the program and improve its readability
Answer : C
Explanation : A comment is a programmer-readable explanation in a program’s code, script, or another file that is not meant to be seen by the user running the program.
Java MCQ
16. In Java , a try block should immediately followed by one or more
Answer : C
Explanation : Every try block should be immediately followed either by a catch block or finally block.
17. When one object acquires the properties of another objects is called
Answer : D
Explanation : Inheritance use a facilities to initilize one class property in another class.
18. Multiple inheritance means
Answer : A
Explanation : Multiple Inheritance is a feature of object oriented concept, where a class can inherit properties of more than one parent class.
19. The wrapping of data and functions into a single units is called
Answer : A
Explanation : The wrapping up of data and functions into a single unit (Class) is known as Encapsulation.
20. Which of the following has a method name flush ()
Answer : B
Related Links