Java - Programming Language (MCQ) questions

Dear Readers, Welcome to Java multiple choice questions and answers with explanation. These objective type Java questions are very important for campus placement test and job interviews.

Specially developed for the Java freshers and professionals, these model questions are asked in the online technical test and interview of many IT companies.

1)   Java: AWT is used for GUI programming in java?
- Published on 29 Jun 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
The AWT contains a large number of classes and methods which allows us to create and manage the windows GUI application. AWT is not only merely used because most of the GUI java programs are implemented using swing but but because of its rich implementation of the GUI controls and nature.


2)   Java: Which is a component in AWT that can contain another components like buttons, textfields, labels etc.?
- Published on 29 Jun 15

a. Window
b. Container
c. Panel
d. Frame
Answer  Explanation 

ANSWER: Container

Explanation:
A container is a component itself and it adds a capability to add a component to itself. A container can add only a component to itself.


3)   Java: Which servlet does struts framework use?
- Published on 29 Jun 15

a. EntryServlet
b. StrutsServlet
c. ActionServlet
d. BasicServlet
Answer  Explanation 

ANSWER: ActionServlet

Explanation:
The ActionServlet provides a "controller" in the Model-View-Controller (MVC) design pattern for web applications which is commonly known as "Model 2". Struts Flow start with ActionServlet then call to process() method of RequestProcessor.


4)   Java: The struts 2 framework is used to develop MVC- based web application
- Published on 29 Jun 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
The struts 2 framework is a combination of webwork framework of open symphony and struts 1.


5)   Java: In which the JDBC type represents a "single precision" floating point number that supports seven digits of mantissa?
- Published on 29 Jun 15

a. REAL
b. DOUBLE
c. FLOAT
d. INTEGER
Answer  Explanation 

ANSWER: REAL

Explanation:
The corresponding SQL type REAL is defined in SQL-92 and is widely, though not universally, supported by the major databases. The SQL-92 standard leaves the precision of REAL up to the implementation.


6)   Java: In which model a Java applet or application talks directly to the data source?
- Published on 29 Jun 15

a. Two-tier models
b. Three-tier models
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Two-tier models

Explanation:
A two-tier model is based on the client – server architecture. There is a direct communication between the client and server. It will run faster because of the tight coupling.


7)   Java: A JDBC technology-based driver ("JDBC driver") makes it possible to do
- Published on 29 Jun 15

a. Establish a connection with a data source
b. Send queries and update statements to the data source
c. Process the results
d. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
A JDBC Driver is a component which enable a java application to interact with a database.


8)   Which of the following methods are members of the Vector class and allow you to input a new element? (Java)
- Published on 26 Jun 15

a. addElement
b. insert
c. append
d. addItem
Answer  Explanation 

ANSWER: addElement

Explanation:
The add element is used to add specified components to the end of the vector and increase its size by one. The addElement() does not return any value.


9)   What can cause a thread to stop executing? (Java)
- Published on 26 Jun 15

a. The program exits via a call to System.exit(0);
b. Another thread is given a higher priority
c. A call to the thread's stop method
d. All of the above
Answer  Explanation 

ANSWER: All of the above

Explanation:
There are various ways by which a thread can stop executing like the stop() or exit() command. Maybe a higher priority thread comes in or even some system problems may occur.


10)   Which of the following statements are correct? (Java)
- Published on 26 Jun 15

a. If multiple listeners are added to a component only events for the last listener added will be processed
b. If multiple listeners are added to a component the events will be processed for all but with no guarantee in the order
c. Adding multiple listeners to a comnponent will cause a compile time error
d. You can not remove or add listeners to a component.
Answer  Explanation 

ANSWER: If multiple listeners are added to a component the events will be processed for all but with no guarantee in the order

Explanation:
Listeners are known as interfaces. Whenever a listener is created all the methods of the listener should be implemented.


1 2 3