java mcq -sem
java mcq -sem
A. instanceOf
B. import
C. extends
D. implement
32. Which of the following packages is used to includes classes to create user interface like
Button and Checkbox?
A. java.lang
B. java.net
C. java.awt
D. java.io
A. Classes
B. Sub Packages
C. Interfaces
D. All of the above
A. Public
B. private
C. Protected
D. All of the mentioned
38. Which of these keywords is used by a class to use an already defined interface?
a) import
b) import
C) tools
d) Implements
A. Compiler Error
B. Compiles and runs fine
C. Compiles fine but throws ArithmeticException exception
D. NONE
42. What is difference between starting thread with run() and start() method?
a.There is no difference
b.When you call start() method, main thread internally calls run() method to start newly
created Thread
c.run() calls start() method internally
d.None
a.Class
b.Interface
c.Abstract class
d.Other
a.throws
b.finally
c.catch
d.throw
a.notify/notifAll
b.When sleep time is up
c.Using resume() method when thread was suspended
d.All
--------------------------------------------------------------------------------
46. The InputStream class defines methods for performing input functions such as
i) reading bytes ii) closing streams
iii) skipping ahead in a stream iv) flushing streams
A) ii, iii and iv only
B) i, ii and iii only
C) i, iii and iv only
D) All i, ii, iii and iv
48. The method …………………., force writes whenever the data accumulates in the
output stream.
A) write( )
B) flush( )
C) read( )
D) reset( )
49. The ……………………… method of the BufferedReader class is used for reading
lines of text from the console, the file or other input streams.
A) read( )
B) read(byte[]b)
C) readLine( )
D) readByte( )
50. The ……………………. class implements the DataInput and DataOutput interfaces
for performing I/O using the primitive data types.
A) RandomAccessFile
B) OutputStream Reader
C) InputStreamReader
D) DataOutputStream
51. If you want to assign a value of 88 to the variable year, then which of the
following lines can be used within an <applet> tag.
A) number = getParameter(88)
B) <number=99>
C) <param = radius value=88>
D) <param name=number value=88>
52. The graphics class provides methods to draw a number of graphical figure
including
i) Text ii) Lines iii) Images iv) Ellipse
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) All i, ii, iii and iv
53. The ………………. method is defined by the AWT which causes the AWT runtime
system to execute a call to your applet’s update( ) method.
A) update( )
B) paint( )
C) repaint( )
D) reupdate( )
54. We can change the text to be displayed by an applet by supplying new text to be
displayed by an applet by supplying new text to the applet through a
……………………… tag.
A) <EDIT>
B) <CHANGE>
C) <REPLACE>
D) <PARAM>
55. Applet class is a subclass of the panel class, which is again a subclass of the
………………….. class.
A) object
B) component
C) awt
D) container
57. Select all the reasons that make String perfect candidate for
Map key?
A. String is immutable
B. String is final
C. String properly implements hashCode() and equals() method
C. All the above
58. Which of these class is used to create an object whose character sequence is
mutable?
A. String()
B. StringBuffer()
A. Hell
B. ello
C. Hel
D. llo
C. replace() method replaces all the characters in invoking string with another
character.
--------------------------------------------------------------------------------------------------
61. In Graphics class which method is used to draws a rectangle with the specified
width and height?
C. public abstract void drawLine(int x1, int y1, int x2, int y2)
A. Window
B. Panel
C. Dialog
D. Frame
A. Labels
B. Pushbuttons
C. Checkboxes
d All of these
a. Graphics class
b. Component class
c. Both A & B
d. None of the above
65. Which is the container that doesn't contain title bar and MenuBars but it can have
other components like button, textfield etc?
Window
b. Frame
c. Panel
d. Container
66. Give the abbreviation of AWT?
Labels
b. Choice
c. List
d. Checkbox
69. Which of the following are passed as an argument to the paint( ) method?
A Canvas object
A Graphics object
An Image object
A paint object
74. Which colour is used to indicate instance methods in the standard "javadoc"
format documentation:
1) blue
2) red
3) purple
4) orange
75. What is the correct ordering for the import, class and package declarations when
found in a single file?
1) package, import, class
2) class, import, package
3) import, package, class
4) package, class, import