Programming MCQs

Java Multiple Choice Questions With Answers set-6

Google+ Pinterest LinkedIn Tumblr
Here are the collection of java multiple choice questions which includes MCQ questions on fundamental of java programming. It includes multiple-choice questions on fundamentals of JSP, Java classes, fundamentals of Java bean, and Java Servlets.

1. JSP embeds in ……………. in ………………….
A) Servlet, HTML
B) HTML, Java
C) HTML, Servlet
D) Java, HTML

2. The class at the top of the exception class hierarchy is ……………………..
A) ArithmeticException
B) Throwable
C) Class
D) Exception

3. In a java program, package declaration ……………….. import statements.
A) must precede
B) must succeed
C) may precede or succeed
D) none

4. The class string belongs to ………………. package.
A) java.awt
B) java.lang
C) java.applet
D) java.string

5. …………… package is used by the compiler itself. So it does not need to be imported for use.
A) java.math
B) java.awt
C) java.applet
D) java.lang

6. State true or false for the following statements in Java.
i) Java beans slow down the software development process.
ii) Java Servlets do not have a built-in multi-threading feature.
A) i-false, ii-false
B) i-false, ii-true
C) i-true, ii-false
D) i-true, ii-true

Read Also: Java Multiple Choice Questions With Answers

7. State whether true or false.
i) init( ) of the servlet is called after a client request comes in
ii) Servlets are ultimately converted into JSP
A) i-false, ii-false
B) i-false, ii-true
C) i-true, ii-false
D) i-true, ii-true

8. What will be the result of compiling following code.
public class MyClass{
public static void main(String args[]){
System.out.println(“In first main()”);
public static void main(char args[]){

A) Code will not compile and will give “Duplicate main() method declaration” error
B) Code will compile correctly but will give a runtime  exception
C) Code will compile correctly and will print “In first main()” (without quotes) when it is run
D) Code will compile correctly and will print “a” (without quotes) when it is run

9. Match the following.
a) Java                      1) is a tool for debugging java program
b) Javah                    2) is a tool for creating C-like header files
c) Javap                    3) runs java bytecode
d) jdb                        4) prints java code representation

A) a-3, b-2,c-1
B) a-3, b-2, c-4, d-1
C) a-1, b-2, c-3, d-4
D) a-2, b-1, c-3, d-4

10.State true or false.
i) init() is called after start() in applet
ii) applets are used for networking
iii) inheritance is a part of Java Foundation Classes
iv) final does not prevent inheritance

A) i-true, ii-true, iii-false, iv-true
B) i-false, ii-false, iii-false, iv-false
C) i-true, ii-true, iii-true, iv-true
D) i-true, ii-false, iii-false, iv-false


1.  D) Java, HTML
2.  B) Throwable
3.  A) must precede
4.  B) java.lang
5.  D) java.lang
6.  A) i-false, ii-false
7.  A) i-false, ii-false
8.  C) Code will compile correctly and will print “In first main()” (without quotes) .. run
9.  B)  a-3, b-2, c-4, d-1
10.B) i-false, ii-false, iii-false, iv-false

Read Next: MCQ of Java With Answer set-7
Read More: Collection of Java MCQ Questions and Answers

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Write A Comment