Programming MCQs

Top 20 Objective Questions on Core Java set-2

Pinterest LinkedIn Tumblr
Here is the collection of the top 20 objective questions on core Java including multiple-choice questions on the core Java features. It includes objective-type questions on implementing the Runnable interface, valid ways to create DataInptStream streams, use of the valueOf() method and the abstract window toolkit(AWT) used on Java.

Read Also: MCQ on Core Java with Answers set-1

1) The methods wait() and notify() are defined in
A. java.lang.String
B. java.lang.Runnable
C. java.lang.Object
D. java.lang.Thread

2) The data or variables, defined within a class are called ….. variables.
A. object
B. class
C. instance
D. schema

3) When we implement the Runnable interface, we must define the method.
A. start()
B. init()
C. run()
D. resume()

4) …….. class must give a concrete method.
A. abstract
B. constructor
C. least
D. program

5) Which exception is thrown by the read() method of the input stream class?
A. Exception
B. FileNotFoundException
C. ReadException
D. IOException

6) When a method calls itself, it is called ……
A. recursion
B. distance
C. display
D. problem

7) Which of the following statements is true?
i) An abstract class may not have any final methods.
ii) A final class may not have any abstract methods
iii) An inner class may be declared with any accessibility keyword
iv) Transient variable must be static
A. i and ii
B. ii and iii
C. iii and iv
D. All i, ii, iii and iv

8) Which of the following statements is/are false?
A. A java monitor must either extend the thread or implement runnable
B. The sleep() method should be enclosed in the try …. catch block.
C. A thread can be temporarily suspended from running by using the wait() method.
D. A suspended thread using suspend() method can be received using the resume() method.

9) What does J2SE mean?
A. Java 2 Platform Standard Edition
B. Java 2 Internet Standard Edition
C. Java 2 System Edition
D. Java 2 Platform Independent Standard Edition

10) An …….. is a special kind of Java program that is designed to be transmitted over the Internet.
A. viewlet
B. applet
C. servlet
D. object

11) What are the valid ways to create DataInptStream streams?
A. new DataInputStream();
B. new DataInputStream(“in.dat’, “r”);
C. new DataInputStream(new File(“in.dat”));
D. new DataInputStream(new FileInputStream(“in.dat”);

12) finalize() is only called just prior to …..
A. initialization
B. runtime
C. garbage collection
D. destruction

13) When we invoke repaint() for a component, the AWT invokes the method
A. draw()
B. show()
C. update()
D. paint()

14) What is the use of the valueOf() method?
A. It converts data from its internal format into a human-readable form.
B. It converts integer value to the string
C. It converts the string to the int value
D. It converts the string to a float value

15) What is the default thread at the time of starting the program?
A. Main thread
B. Thread Group
C. Child Thread
D. Thread Pool

16) What does the following line of code do?
       TextField text= new TextField(10);
A. Creates text object that can hold 10 rows of text
B. Creates text object that can hold 10 columns of text
C. Creates the object text and initialize it with the value 10
D. The code is illegal

17) ………. is an applet tag.
A. (applet)
B. >applet<
C. <applet>
D. <applet tag>

18) In Java thread to thread communication is called ……
A. Passing
B. sending
C. Messaging
D. Calling

19) AWT stands for
A. abstract window toolkit
B. abstract window toolbar
C. access window toolbar
D. access window toolbar

20) The setBackground() method is part of the class
A. Graphics
B. Applet
C. Component
D. Container

Answers:

1) C. java.lang.Object
2) C. instance
3) C. run()
4) A. abstract
5) D. IOException
6) A. recursion
7) B. ii and iii
8) A. A java monitor must either extend the thread or implement runnable
9) A. Java 2 Platform Standard Edition
10) B. applet
11) D. new DataInputStream(new FileInputStream(“in.dat”);
12) C. garbage collection
13) C. update()
14) D. It converts the string to a float value
15) A. Main thread
16) B. Creates text object that can hold 10 columns of text
17) C. <applet>
18) C. Messaging
19) A. abstract window toolkit
20) C. Component

Read Next: Objective Questions on Core Java set 3

Author

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.

Comments are closed.