

MCQOPTIONS
Saved Bookmarks
This section includes 215 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
51. |
Consider the following list.list = {24, 20, 10, 75, 70, 18, 60, 35} Suppose that list is sorted using the selection sort algorithm as discussed in the book. What is the resulting list after two passes of the sorting phase, that is, after two iteration of the outer for loop? |
A. | list = {10, 18, 24, 20, 75, 70, 60, 35} |
B. | list = {10, 18, 20, 24, 75, 70, 60, 35} |
C. | list = {10, 18, 24, 75, 70, 20, 60, 35} |
D. | None of these |
Answer» D. None of these | |
52. |
The class RuntimeException is the superclass of which of the following classes? |
A. | NullPointerException |
B. | NoSuchMethodException |
C. | IllegalAccessException |
D. | NoSuchFileException |
Answer» B. NoSuchMethodException | |
53. |
What garbage collection in the context of java? |
A. | The operating system periodically deletes all of the java files available on the system. |
B. | Any package imported in a program and not used in automatically deleted. |
C. | When all references to an object are gone, the memory used by the object is automatically reclaim |
Answer» D. | |
54. |
Which of these methods can be used to obtain the command name for ActionEvent object? |
A. | getCommand() |
B. | getActionCommand() |
C. | getActionEvent() |
D. | getActionEventCommand() |
Answer» C. getActionEvent() | |
55. |
Which operator is used to implement unsigned right shift of an integer? |
A. | << |
B. | >> |
C. | <<< |
D. | >>> |
Answer» E. | |
56. |
Which of these methods can be used to obtain the command name for invoking ActionEventobject? |
A. | getCommand() |
B. | getActionCommand() |
C. | getActionEvent() |
D. | getActionEventCommand() |
Answer» C. getActionEvent() | |
57. |
Java source files are compiled and converted to |
A. | Object code |
B. | machine code |
C. | Bytecode |
D. | executable file |
Answer» D. executable file | |
58. |
Consider the following code snippet String river = new String(“Columbia”); System.out.println(river.length()); What is printed? |
A. | 6 |
B. | 7 |
C. | 8 |
D. | Columbia |
Answer» D. Columbia | |
59. |
____________ 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» D. RMI Registry | |
60. |
Which of these coding types is used for data type char in Java? |
A. | ASCII |
B. | ISO-LATIN-1 |
C. | UNICODE |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
61. |
An Applet has its Layout Manager set to the default of FlowLayout. What code would bethe correct to change to another Layout Manager? |
A. | setLayoutManager(new GridLayout()); |
B. | setLayout(new GridLayout(2,2)); |
C. | setGridLayout(2,2); |
D. | setBorderLayout(); |
Answer» C. setGridLayout(2,2); | |
62. |
Which of these exception is thrown by close () and read () methods? |
A. | IOException |
B. | FileException |
C. | FileNotFoundException |
D. | FileInputOutputException |
Answer» B. FileException | |
63. |
If there are three classes: Shape, Circle, and Square, what is the most likely relationship between them? |
A. | Square is a superclass, and Shape and Circle are subclasses of Square. |
B. | Shape is a superclass, and Circle and Square are subclasses of Shape. |
C. | Shape, Circle, and Square are all sibling classes. |
D. | These three classes cannot be related. |
Answer» C. Shape, Circle, and Square are all sibling classes. | |
64. |
Consider public class MyClass{ public MyClass(){/*code*/} // more code... } To instantiate MyClass, you would write? |
A. | MyClass mc = new MyClass(); |
B. | MyClass mc = MyClass(); |
C. | MyClass mc = MyClass; |
D. | MyClass mc = new MyClass; 7. E. It can't be done. The constructor of MyClass should be defined as public void MyClass(){/*code*/} |
Answer» B. MyClass mc = MyClass(); | |
65. |
The class used for drawing graphics in an application is |
A. | Canvas |
B. | Graphics |
C. | Layer |
D. | Container |
Answer» C. Layer | |
66. |
Which is a one-way communication only between the client and the server and it is not a reliable and there is no confirmation regarding reaching the message to the destination? |
A. | TCP/IP |
B. | UDP |
C. | Both A & B |
D. | None of the above |
Answer» C. Both A & B | |
67. |
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» E. | |
68. |
In RMI applications which program obtains a remote reference to one or more remote objects on a server and then invokes methods on them? |
A. | Server |
B. | Client |
C. | Both A & B |
D. | None of the above |
Answer» C. Both A & B | |
69. |
In Java Inheritance |
A. | all fields of a class are private |
B. | all fields of a class are protected |
C. | a new class is derived from an existing class |
D. | none of these above |
Answer» D. none of these above | |
70. |
Defining methods with same name and different no. of parameters are called |
A. | Method overriding |
B. | method overloading |
C. | Dynamic method dispatch |
D. | none of the above |
Answer» C. Dynamic method dispatch | |
71. |
The code within the ----------- block will always be executed whether or not an exception is thrown. |
A. | try..catch |
B. | finally |
C. | throw |
D. | throws |
Answer» C. throw | |
72. |
The keyword used to refer the current object |
A. | class |
B. | this |
C. | new |
D. | malloc |
Answer» C. new | |
73. |
Which of the following exception is raised when a number is divided by zero |
A. | NumberFormatException |
B. | ArithmeticException |
C. | NullPointerException |
D. | IllegalArgumentException |
Answer» C. NullPointerException | |
74. |
If an expression contains double, int, float, long, then the whole expression will be promotedinto which of these data types? |
A. | long |
B. | int |
C. | double |
D. | float |
Answer» D. float | |
75. |
Variables declared within a method or block are called |
A. | Static variable |
B. | local variable |
C. | instance variable |
D. | global variable |
Answer» C. instance variable | |
76. |
Consider the following program:import myLibrary.*; public class ShowSomeClass { // code for the class... } What is the name of the java file containing this program? |
A. | myLibrary.java |
B. | ShowSomeClass.java |
C. | ShowSomeClass |
D. | ShowSomeClass.class 1. |
Answer» C. ShowSomeClass | |
77. |
Which exception is thrown by the read ( ) method of input stream class? |
A. | Exception |
B. | ClassNotFoundException |
C. | read Exception |
D. | IOException |
Answer» E. | |
78. |
If a thread is to be declared as a daemon thread, it must be declared before |
A. | start method |
B. | run method |
C. | stop method |
D. | none |
Answer» B. run method | |
79. |
For the interface WindowListener that contains more than one method, Java provides theclass ____. |
A. | MouseAdapter |
B. | WindowAdapter |
C. | KeyListener |
D. | KeyAdapter |
Answer» C. KeyListener | |
80. |
What is the size of int data type in java? |
A. | 1 bytes |
B. | 2 bytes |
C. | 4 bytes |
D. | 8 bytes |
Answer» D. 8 bytes | |
81. |
What is different between a Java applet and a Java application? |
A. | An application can in general be trusted whereas an applet can't. |
B. | An applet must be executed in a browser environment. |
C. | An applet is not able to access the files of the computer it runs on |
D. | (A), (B) and (C). |
Answer» E. | |
82. |
A ------------ is an object that the user can see on the screen and-in most cases-interact with. |
A. | an Event |
B. | a window |
C. | a Component |
D. | a Listener |
Answer» D. a Listener | |
83. |
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» C. Either (a) or (b) | |
84. |
Which is a valid float literal? |
A. | 1.23 |
B. | 2 |
C. | 1.23d |
D. | 1.23f |
Answer» E. | |
85. |
Which of these class is super class of all AWT events? |
A. | AWTEvent |
B. | EventClass |
C. | ActionEvent |
D. | ItemEvent |
Answer» B. EventClass | |
86. |
In a ____ control structure, the computer executes particular statements depending on some condition(s). |
A. | looping |
B. | repetition |
C. | selection |
D. | sequence |
Answer» D. sequence | |
87. |
Which of this access specifies can be used for a class so that its objects can be created by a different class in another package? |
A. | Public |
B. | Protected |
C. | No Modifier |
D. | All of the mentioned |
Answer» B. Protected | |
88. |
Which method executes only once |
A. | start() method |
B. | init() method |
C. | stop() method |
D. | destroy() method |
Answer» C. stop() method | |
89. |
How many kinds of classes can be used in Java RMI? |
A. | One |
B. | Two |
C. | Three |
D. | Four |
Answer» C. Three | |
90. |
Which is the container that doesn't contain title bar and MenuBars. It can have othercomponents like button, textfield etc? |
A. | Window |
B. | Frame |
C. | Panel |
D. | Container |
Answer» D. Container | |
91. |
Identify the type of inheritance when two or more subclasses inherit the properties of a super class. |
A. | Multiple inheritance |
B. | Single inheritance |
C. | Multilevel inheritance |
D. | Hierarchical inheritance |
Answer» E. | |
92. |
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» B. getModifier() | |
93. |
Java Stream classes can be categorized into two groups: |
A. | Byte and Character Stream Classes |
B. | Stream and String Classes |
C. | String and Character Stream Classes |
D. | Buffer and Character Stream Classes |
Answer» B. Stream and String Classes | |
94. |
Whenever the applet requires to redraw its output, it is done by using method |
A. | display() |
B. | paint() |
C. | displayApplet() |
D. | PrintApplet() |
Answer» C. displayApplet() | |
95. |
The layout manager that lays out a container's components in a rectangular grid. |
A. | BorderLayout |
B. | GridLayout |
C. | FlowLayout |
D. | GridBagLayout |
Answer» C. FlowLayout | |
96. |
What is the stored in the object obj in following lines of code? box obj; |
A. | Memory address of allocated memory of object. |
Answer» C. | |
97. |
What is the default buffer size used by any buffered class? |
A. | 128 bytes |
B. | 256 bytes |
C. | 512 bytes |
D. | 1024 bytes |
Answer» D. 1024 bytes | |
98. |
The _______ class is used to write bytes to a file: |
A. | FileInputStream |
B. | FileOutputStream |
C. | FileBufferStream |
D. | FileStringStream |
Answer» C. FileBufferStream | |
99. |
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() method |
D. | Use the updateLayout() method |
Answer» B. Once created you cannot change the current layout manager of a component | |
100. |
Which of these classes is related to all the exceptions that can be caught by using catch? |
A. | Error |
B. | Exception |
C. | None of these |
D. | a & b |
Answer» C. None of these | |