219
95.1k

610+ Java Programming Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Bachelor of Computer Applications (BCA) , Bachelor of Science in Computer Science (BSc CS) , Master of Computer Applications (MCA) , Programming Languages .

251.

Which statement is static and synchronized in JDBC API?

A. executeQuery()
B. executeUpdate()
C. getConnection()
D. prepareCall()
Answer» C. getConnection()
252.

Which driver is efficient and always preferable for using JDBC applications?

A. Type – 4
B. Type – 1
C. Type – 3
D. Type – 2
Answer» A. Type – 4
253.

Which one of the following does not extends java.awt.Component

A. CheckBox
B. Canvas
C. CheckbocGroup
D. Label
Answer» C. CheckbocGroup
254.

What is default layout manager for panels and applets?

A. Flowlayout
B. Gridlayout
C. BorderLayout
D. none
Answer» A. Flowlayout
255.

java.awt.Component class method getLocation() returns Point (containg x and y cordinate).What does this x and y specify

A. Specify the postion of components lower-left component in the coordinate space of the component's parent.
B. Specify the postion of components upper-left component in the coordinate space of the component's parent.
C. Specify the postion of components upper-left component in the coordinate space of the screen.
D. none
Answer» B. Specify the postion of components upper-left component in the coordinate space of the component's parent.
256.

Which of the following methods finds the maximum number of connections that a specific driver can obtain?

A. Database.getMaxConnections
B. Connection.getMaxConnection
C. DatabaseMetaData.getMaxConnections
D. ResultSetMetaData.getMaxConnections
Answer» C. DatabaseMetaData.getMaxConnections
257.

What is the disadvantage of Type-4 Native-Protocol Driver?

A. At client side, a separate driver is needed for each database.
B. Type-4 driver is entirely written in Java
C. The driver converts JDBC calls into vendor-specific database protocol
D. It does not support to read MySQL data.
Answer» A. At client side, a separate driver is needed for each database.
258.

What is the preferred way to handle an object's events in Java 2?

A. Override the object's handleEvent( ) method.
B. Add one or more event listeners to handle the events
C. Have the object override its process Event ( ) methods.
D. Have the object override its dispatch Event ( ) methods.
Answer» B. Add one or more event listeners to handle the events
259.

Which component method is used to access a component's immediate container?

A. getVisible()
B. getImmediate()
C. getParent()
D. getContainer()
Answer» C. getParent()
260.

Which of the following creates a List with 5 visible items and multiple selections enabled?

A. new List(5, true)
B. new List(true, 5)
C. new List(5, false)
D. new List(false, 5)
Answer» A. new List(5, true)
261.

An Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to change to another Layout Manager?

A. setLayoutManager(new GridLayout());
B. setLayout(new GridLayout(2,2));
C. setGridLayout(2,2);
D. setBorderLayout();
Answer» B. setLayout(new GridLayout(2,2));
262.

How do you change the current layout manager for a container?

A. Use the setLayout method.
B. Once created you cannot change the current layout manager of a component
C. Use the setLayoutManager meth
Answer» A. Use the setLayout method.
263.

Which of the following methods can be used to draw the outline of a square within a JAVA.awt.Component object?

A. drawLine()
B. fillRect()
C. drawPolygon()
D. drawPolygon()
Answer» A. drawLine()
264.

State true or false (i) JPanel is a class included in awt package (ii) Anonymous classes are mostly used for event handling (iii) Names of anonymous classes must be unique (iv) JOptionPane is an inner class

A. i-false, ii-false, iii-true, iv-true
B. i-true, ii-false, iii-true, iv-false
C. i-false, ii-true, iii-false, iv-false
D. i-true, ii-true, iii-false, iv-true
Answer» C. i-false, ii-true, iii-false, iv-false
265.

State true or false (i) Java RMI supports distributed objects written entirely in java (ii) Java RMI makes use of stubs and skeleton (iii) In Java RMI an object registers itself with a media server (iv) IDL is interface declaration language

A. True, True, False, False
B. False, True, True, True
C. True, False, True, False
D. True, True, True, True
Answer» A. True, True, False, False
266.

Match the following
(a) Datagram Socket (i) UDP connection
(b) URL (ii) provides a necessary framework of debugging java programs
(c) java.net (iii) makes it possible to communicate over a network with java programs
(d) sun.tools.debug (iv) is a java object that represents WWW address

A. a-i, b-iv, c-iii, d-ii
B. a-i, b-iv, c-ii, d-iii
C. a-ii, b-iii, c-i, d-iv
D. a-ii, b-i, c-iii, d-iv
Answer» A. a-i, b-iv, c-iii, d-ii
267.

State true or false (i) public can only be assigned to class (ii) protected protects a statement (iii) protected method is never accessible outside the package (iv) friendly variable may be accessible outside class

A. True, True, False, True
B. False, False, False, True
C. False, True, False, False
D. True, False, False, False
Answer» A. True, True, False, True
268.

Which refers to a channel through which data flow from the source to the destination:

A. String
B. Character
C. Stream
D. Buffer
Answer» C. Stream
269.

The ________ method help in clearing the contents of the buffer:

A. flush()
B. clear()
C. rub()
D. vanish()
Answer» C. rub()
270.

Which of these methods can be used to output a string in an applet?

A. display()
B. print()
C. drawString()
D. transient()
Answer» C. drawString()
271.

Which of these methods are used to register a MouseMotionListener?

A. addMouse()
B. addMouseListener()
C. addMouseMotionListner()
D. eventMouseMotionListener()
Answer» C. addMouseMotionListner()
272.

What is a listener in context to event handling?

A. A listener is a variable that is notified when an event occurs.
B. A listener is an interface that is notified when an event occurs.
C. A listener is a method that is notified when an event occurs.
D. None of the mentioned
Answer» B. A listener is an interface that is notified when an event occurs.
273.

Which of these events will be generated if scroll bar is manipulated?

A. ActionEvent
B. ComponentEvent
C. AdjustmentEvent
D. WindowEvent
Answer» D. WindowEvent
274.

Which of these events will be generated if we close a Frame window?

A. ActionEvent
B. ComponentEvent
C. AdjustmentEvent
D. WindowEvent
Answer» D. WindowEvent
275.

Which of these methods in KeyEvent class can be used to know which key is pressed?

A. getKeyCode()
B. getModifier()
C. getActionKey()
D. getActionEvent()
Answer» A. getKeyCode()
276.

The default layout manager of an Applet is

A. Flowlayout
B. Gridlayout
C. BorderLayout
D. BoxLayout
Answer» A. Flowlayout
277.

The processes that participate in supporting remote method invocation are

A. Client
B. Server
C. Object Registry
D. All of the above
Answer» D. All of the above
278.

Through the design mode of a builder tool, we use ___ or ____ to customize the bean.

A. Property sheet
B. Bean customizer
C. Either (a) or (c)
D. None of the above
Answer» C. Either (a) or (c)
279.

Swing is a ___________ framework

A. connection-based
B. component-based
C. platform-based
D. None of the above
Answer» B. component-based
280.

How many kinds of classes can be used in Java RMI?

A. One
B. Two
C. Three
D. Four
Answer» B. Two
281.

Which method is used to enable an event for a particular object?

A. enableEvent()
B. enable()
C. enableObject()
D. enableEvents()
Answer» D. enableEvents()
282.

How would you detect a keypress in a JComboBox?

A. Add a KeyListener to the JComboBox
B. Add a KeyListener to the JComboBox’s editor component
C. Either (a) or (b)
D. None of the above
Answer» B. Add a KeyListener to the JComboBox’s editor component
283.

Which Swing methods are thread-safe?

A. repaint()
B. revalidate()
C. invalidate()
D. all of the above
Answer» D. all of the above
284.

Which of the following is not true?

A. The Frame class extends Window
B. The CheckboxMenuItem class extends the MenuItem class
C. JComponent is a subclass of Container
D. None of the above
Answer» D. None of the above
285.

What is the correct way to write a JavaScript array?

A. var txt = new Array:1=("tim")2=("kim")3=("jim")
B. var txt = new Array(1:"tim",2:"kim",3:"jim")
C. var txt = new Array="tim","kim","jim")
D. var txt = new Array("tim","kim","jim")
Answer» D. var txt = new Array("tim","kim","jim")
286.

What is the correct JavaScript syntax to insert a comment that has more than one line?

A. <!--This comment has more than one line-->
B. /*This comment has more than one line*/
C. //This comment has more than one line//
D. <//This comment has more than one line//>
Answer» B. /*This comment has more than one line*/
287.

What is Remote method invocation (RMI)?

A. RMI allows us to invoke a method of java object that executes on another machine.
B. RMI allows us to invoke a method of java object that executes on another Thread in multithreaded programming.
C. RMI allows us to invoke a method of java object that executes parallely in same machine.
D. None of the mentioned
Answer» A. RMI allows us to invoke a method of java object that executes on another machine.
288.

Which of this package is used for remote method invocation?

A. java.applet
B. java.rmi
C. java.lang.rmi
D. java.lang.reflect
Answer» B. java.rmi
289.

Which of these methods are member of Remote class?

A. checkIP()
B. addLocation()
C. AddServer()
D. None of the mentioned
Answer» D. None of the mentioned
290.

Which of these Exceptions is thrown by remote method?

A. RemoteException
B. InputOutputException
C. RemoteAccessException
D. RemoteInputOutputException
Answer» A. RemoteException
291.

Which of this class is used for creating a client for server-client operations?

A. serverClientjava
B. Client.java
C. AddClient.java
D. ServerClient.java
Answer» C. AddClient.java
292.

Which of this package is used for all the text related modifications?

A. java.text
B. java.awt
C. java.lang.text
D. java.text.mofify
Answer» A. java.text
293.

Which of this package contains classes and interfaces for networking?

A. java.io
B. java.util
C. java.net
D. java.network
Answer» C. java.net
294.

Which of these is superclass of ContainerEvent class?

A. WindowEvent
B. ComponentEvent
C. ItemEvent
D. InputEvent
Answer» B. ComponentEvent
295.

Which of these events is generated when the size os an event is changed?

A. ComponentEvent
B. ContainerEvent
C. FocusEvent
D. InputEvent
Answer» A. ComponentEvent
296.

Which of these methods can be used to obtain the reference to the container that generated a ContainerEvent?

A. getContainer()
B. getContainerCommand()
C. getActionEvent()
D. getContainerEvent()
Answer» D. getContainerEvent()
297.

To locate a remote object with a name t at port 7000 on host panda.armstrong.edu, use

A. Remote remoteObj = Name.lookup("rmi://panda.armstrong.edu:7000/t");
B. Remote remoteObj = Name.lookup("//panda.armstrong.edu:7000/t");
C. Remote remoteObj = Name.lookup("http://panda.armstrong.edu:7000/t");
D. Remote remoteObj = Naming.lookup("rmi://panda.armstrong.edu:7000/t");
Answer» D. Remote remoteObj = Naming.lookup("rmi://panda.armstrong.edu:7000/t");
298.

____________ is a subinterface of java.rmi.Remote that defines the methods for the server object.

A. Server stub
B. Server implementation
C. Server object interface
D. RMI Registry
Answer» C. Server object interface
299.

Each remote object has a unique name identified by an URL with the protocol rmi as follows:

A. http://host:port/name
B. //host:port/name
C. http://host/name
D. rmi://host:port/name
Answer» B. //host:port/name
300.

__________ provides the naming services for the server to register the object and for the client to locate the object.

A. Server stub
B. RMI Registry
C. Server implementation
D. Server Skeleton
Answer» B. RMI Registry

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.