Java Suggestion
Java Suggestion
Topic: Miscellaneous
1. What are the different ways by which String, class, and object can be created in Java?
2. What is the role of an abstract class in Java?
3. What is the order of calling constructors in multi-level inheritance in Java?
4. What is the difference between static loading and dynamic class loading in Java?
5. How can the process of creating and implementing interfaces in Java be explained?
Highlight their role in achieving multiple inheritance.
6. What is the significance of the "super" keyword in Java inheritance? How is it used to
call a superclass constructor?
7. What is the concept of a multilevel hierarchy in inheritance in Java? Provide an
example demonstrating its use.
8. What is the "final" keyword in Java, particularly in the context of inheritance and
method overriding?
9. How are abstract classes and methods utilized in Java? What purpose do they serve in
object-oriented programming?
10. What is the significance of the constructor chaining process in Java inheritance? How
does it ensure proper initialization of objects?
72. Which return type of a method does not return any value in Java?
o int
o void
o float
o double
73. Which keyword can be used to refer to the current class instance variable in Java?
o import
o abstract
o catch
o this
74. Which method of class StringBuffer is used to concatenate the string representation to the
end of a string in Java?
o concatenate()
o concat()
o append()
o join()
75. Which method of class String is used to remove leading and trailing whitespaces?
o trim()
o doTrim()
o replace()
o startsWith()
76. Which method of class String is used to extract a substring from a String object?
o substring()
o stringSub()
o String()
o None of these
77. Which method of class String is used to check whether a given object starts with a particular
string literal?
o startsWith()
o Starts()
o endsWith()
o ends()
78. Which methods are used to write into a file in Java?
o put()
o write()
o putFile()
o writeFile()
79. Which method returns the total number of bytes of memory available to the program in
Java?
o getMemory()
o TotalMemory()
o getProcessMemory()
o SystemMemory()
80. Which method of the String class is used to obtain a character at a specified index?
o CharacAt()
o characterAt()
o char()
o charAt()
81. Which method of the String class can be used to test two strings for equality?
o isqual()
o isequals()
o equal()
o equals()
82. Which of these methods can be used for writing console output in Java?
o print()
o write()
o println()
o All of these
83. How many arguments can be passed to the main() method in Java?
o One
o many
o two
o three
84. Which method of class String is used to compare two String objects for their equality?
o equals
o equal
o isequal
o isequals
85. Which method is used to compare a specific region inside a string with another specific
region in another string?
o regionMatch()
o match()
o RegionMatches()
o regionMatches()
86. What is the data type value returned by the equals() method of the String class in Java?
o char
o int
o boolean
o all of the mentioned
87. When is method overloading determined in Java?
o At run time
o At compile time
o At coding time
o At execution time
88. What in Java "System.out.print" is defined as?
o Method
o Object
o Class
o None of these
89. Which option is incorrect for constructors in Java?
o Constructor has the same name as the class name
o Constructor should have a return type
o A class can contain more than one constructor
o Constructor is automatically invoked whenever an object of the class is created
90. Why should the main method be static in Java?
o It can be accessed easily by the class loader
o It can be accessed by every method
o It can be executed without creating any instance of the class
o All of these
91. What is the correct way of calling a constructor having no parameters of superclass A by
subclass B in Java?
o super(void);
o superclass.();
o super.A();
o super();
final
constant
last
static
101. Which of these keywords can be used to prevent method overriding in Java?
static
constant
final
protected
Intf
intf
interface
int
Protected
Void
Public
Private
106. Which of the below is an invalid identifier with the main method in Java?
public
private
static
final
Integer
String
Double
Boolean
boolean b1 = 1;
boolean b2 = false();
boolean b2 = false;
boolean b1 = 0;
Integer
Character
Boolean
None of these
111. What is the return type of the Greater Than, Less Than, and Equal To (Relational)
operators in Java?
Float
Integer
Boolean
Double
int
byte
short
long
113. In Java, array elements are stored in what type of memory locations?
Random
Sequential
Binary search
Sequential & Random
identifier
keyword
identifier & keyword
none of the mentioned
0 to 256
-128 to 127
0 to 65535
0 to 32767
final class
start class
abstract class
string class
121. What is true about args in the following line of code: public static void main(String
args[])?
args is a String
args is an array of String
args is a Character
args is an array of Character
Integer
String array
Stack
int array
String is a class
Every string is an object of class String
Strings in Java are mutable
Java defines a peer class of String called StringBuffer, which allows strings to be altered
String is a class
Every string is an object of class String
Strings in Java are mutable
Java defines a peer class of String called StringBuffer, which allows strings to be altered
125. Which jump statement can skip processing the remainder of the code in its body for
a particular iteration in Java?
break
return
exit
continue
127. Which option transfers execution to different parts of your code based on the value
of an expression in Java?
if
switch
nested if-else
if-else
break
continue
for()
if()
Run Time
Compilation Time
Can Occur Any Time
None of the mentioned
try
thrown
catch
finally
try
finally
throw
catch
132. Which keyword must be used to handle the exception thrown by the try block in
some rational manner in Java?
try
finally
throw
catch
try
finally
throw
catch
NumberFormatException
ArithmeticException
NullPointerException
None of these
throw
try
catch
None of these
RuntimeExceptions
String
Throwable
Cacheable
137. Which keyword is used for the block to be examined for exceptions in Java?
check
throw
catch
try
Topic: Multithreading
Integer
Float
Double
Character
By multithreading, CPU idle time is minimized, and we can take maximum use of it
By multitasking, CPU idle time is minimized, and we can take maximum use of it
Two threads in Java can have the same priority
A thread can exist only in two states, running and blocked
142. Which of the following is not a method of the Thread class in Java?
yield()
sleep()
go()
stop()
144. Which method is called internally by the Thread start() method in Java?
execute()
run()
launch()
main()
145. When a class extends the Thread class, which method should it override to start that
thread?
join()
start()
run()
go()
147. Which package contains classes and interfaces used for input and output operations
in Java?
java.net
java.io
java.lang
All of these
java.io
java.lang
java.util
java.net
java.util package
java.lang package
java.awt package
java.io package
Class
Variable
Method
Object
Class
Variable
Method
Object
java
Copy
class output {
true true
false false
true false
false true
java
Copy
class multithreaded_programing {
Thread t = Thread.currentThread();
System.out.println(t);
Thread[5,main]
Thread[main,0]
Thread[main,5]
Thread[main,5,main]
155. What is the priority of the thread in the following Java program?
java
Copy
class multithreaded_programing {
Thread t = Thread.currentThread();
System.out.println(t);
4
5
0
1
158. Which class represents a window for a graphical application in Java AWT?
Frame
Panel
Window
Applet
Component
Widget
Container
Control
160. Which layout manager is suitable for arranging components in a grid-like structure in
Java?
BorderLayout
FlowLayout
GridLayout
CardLayout
161. Which event listener interface is used to handle mouse events in Java AWT?
ActionListener
MouseMotionListener
MouseListener
KeyListener
162. Which class provides support for drawing shapes and images on the screen in Java
AWT?
Graphics2D
Canvas
Image
Shape
163. Which method is used to set the font for a component in Java AWT?
setFont()
setStyle()
setFontStyle()
setComponentFont()
164. Which layout manager is used to arrange components in a horizontal or vertical row
in Java?
BorderLayout
FlowLayout
GridLayout
BoxLayout
166. Which class is the superclass for all AWT event classes in Java?
EventObject
Event
AWTEvent
ComponentEvent
168. Which layout manager is typically used to arrange components in a grid format in
Java?
FlowLayout
BorderLayout
GridLayout
CardLayout
A graphical component
A user action or occurrence
A layout manager
A container class
JLabel
JButton
JTextField
JCheckBox
171. What is the main container class used to create a top-level window in a Swing
application?
JFrame
JPanel
JWindow
JDialog
display()
paint()
displayApplet()
PrintApplet()
Topic: Miscellaneous
173. Which option is used by the operating system to manage recursion in Java?
Tree
Array
Queue
Stack
Referring to the instance variable when a local variable has the same name
Passing itself to the method of the same class
Passing itself to another method
Calling another constructor in constructor chaining
176. In Java code, the line that begins with /* and ends with */ is known as what?
Multiline comment
Single line comment
Both A & B
None of these