InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 101. |
Which of this method is used to make all elements of an equal to specified value?(a) add()(b) fill()(c) all()(d) set() |
|
Answer» Right choice is (b) fill() For explanation: fill() method assigns a value to all the elements in an array, in other words, it fills the array with specified value. |
|
| 102. |
Which of these method is used to make a bit zero specified by the index?(a) put()(b) set()(c) remove()(d) clear() |
|
Answer» Correct answer is (d) clear() For explanation: None. |
|
| 103. |
Which of these methods can be used to know the degree of adjustment made by the user?(a) getValue()(b) getAdjustmentType()(c) getAdjustmentValue()(d) getAdjustmentAmount() |
|
Answer» Correct choice is (a) getValue() To elaborate: The amount of the adjustment can be obtained from the getvalue() method, it returns an integer value corresponding to the amount of adjustment made. |
|
| 104. |
Which of these methods can be used to obtain set of all keys in a map?(a) getAll()(b) getKeys()(c) keyall()(d) keySet() |
|
Answer» The correct option is (d) keySet() To explain I would say: keySet() methods is used to get a set containing all the keys used in a map. This method provides set view of the keys in the invoking map. |
|
| 105. |
Which of these method Map class is used to obtain an element in the map having specified key?(a) search()(b) get()(c) set()(d) look() |
|
Answer» Correct answer is (b) get() Easiest explanation: None. |
|
| 106. |
Which of these methods can be used to know which key is pressed?(a) getKey()(b) getModifier()(c) getActionKey()(d) getActionEvent() |
|
Answer» The correct choice is (b) getModifier() The best I can explain: The getModifiers() methods returns a value that indicates which modifiers keys (ALT, CTRL, META, SHIFT) were pressed when the event was generated. |
|
| 107. |
Which of these classes provide implementation of map interface?(a) ArrayList(b) HashMap(c) LinkedList(d) DynamicList |
|
Answer» Correct answer is (b) HashMap The explanation: AbstractMap, WeakHashMap, HashMap and TreeMap provide implementation of map interface. |
|
| 108. |
What happens if ServerSocket is not able to listen on the specified port?(a) The system exits gracefully with appropriate message(b) The system will wait till port is free(c) IOException is thrown when opening the socket(d) PortOccupiedException is thrown |
|
Answer» The correct answer is (c) IOException is thrown when opening the socket The best I can explain: public ServerSocket() creates an unbound server socket. It throws IOException if specified port is busy when opening the socket. |
|
| 109. |
Which of these are integer constants of TextEvent class?(a) TEXT_CHANGED(b) TEXT_FORMAT_CHANGED(c) TEXT_VALUE_CHANGED(d) TEXT_sIZE_CHANGED |
|
Answer» Correct choice is (c) TEXT_VALUE_CHANGED For explanation: TextEvent defines a single integer constant TEXT_VALUE_CHANGED. |
|
| 110. |
Which of these are integer constants of ComponentEvent class?(a) COMPONENT_HIDDEN(b) COMPONENT_MOVED(c) COMPONENT_RESIZE(d) All of the mentioned |
|
Answer» The correct answer is (d) All of the mentioned The best explanation: The component event class defines 4 constants COMPONENT_HIDDEN, COMPONENT-MOVED, COMPONENT-RESIZE and COMPONENT-SHOWN. |
|
| 111. |
Which of these are integer constants defined in ActionEvent class?(a) ALT_MASK(b) CTRL_MASK(c) SHIFT_MASK(d) All of the mentioned |
|
Answer» The correct option is (d) All of the mentioned The explanation: Action event defines 4 integer constants ALT_MASK, CTRL_MASK, SHIFT_MASK and ACTION_PERFORMED |
|
| 112. |
Which of these method is used to remove all keys/values pair from the invoking map?(a) delete()(b) remove()(c) clear()(d) removeAll() |
|
Answer» The correct answer is (b) remove() Easy explanation: None. |
|
| 113. |
What is the value returned by function compareTo() if the invoking string is less than the string compared?(a) zero(b) value less than zero(c) value greater than zero(d) none of the mentioned |
|
Answer» Correct answer is (b) value less than zero Explanation: compareTo() function returns zero when both the strings are equal, it returns a value less than zero if the invoking string is less than the other string being compared and value greater than zero when invoking string is greater than the string compared to. |
|
| 114. |
Which of these is a wrapper for simple data type char?(a) Float(b) Character(c) String(d) Integer |
|
Answer» The correct option is (b) Character For explanation: None. |
|
| 115. |
What is the value returned by function compareTo() if the invoking string is greater than the string compared?(a) zero(b) value less than zero(c) value greater than zero(d) none of the mentioned |
|
Answer» The correct choice is (c) value greater than zero Easy explanation: if (s1 == s2) then 0, if(s1 > s2) > 0, if (s1 < s2) then < 0. |
|
| 116. |
Which of these class have only one field ‘TYPE’?(a) Void(b) Process(c) System(d) Runtime |
|
Answer» Right choice is (a) Void The explanation: The Void class has one field, TYPE, which holds a reference to the Class object for the type void. |
|
| 117. |
Which of these methods is a part of Abstract Window Toolkit (AWT) ?(a) display()(b) paint()(c) drawString()(d) transient() |
|
Answer» The correct option is (b) paint() To explain I would say: paint() is an abstract method defined in AWT. |
|
| 118. |
“request” is instance of which one of the following classes?(a) Request(b) HttpRequest(c) HttpServletRequest(d) ServletRequest |
|
Answer» Correct choice is (c) HttpServletRequest Explanation: request is object of HttpServletRequest. |
|
| 119. |
Which of these interfaces define a method actionPerformed()?(a) ComponentListener(b) ContainerListener(c) ActionListener(d) InputListener |
|
Answer» Correct choice is (c) ActionListener To elaborate: ActionListener defines the actionPerformed() method that is invoked when an adjustment event occurs. |
|
| 120. |
Which of these methods can be used to obtain the command name for invoking ActionEvent object?(a) getCommand()(b) getActionCommand()(c) getActionEvent()(d) getActionEventCommand() |
|
Answer» Right option is (b) getActionCommand() The explanation: None. |
|
| 121. |
Which of the following is method of wrapper Integer for converting the value of an object into int?(a) bytevalue()(b) int intValue();(c) Bytevalue()(d) Byte Bytevalue() |
|
Answer» Right option is (b) int intValue(); To explain: None. |
|
| 122. |
Which of these transfer protocol must be used so that URL can be accessed by URLConnection class object?(a) http(b) https(c) Any Protocol can be used(d) None of the mentioned |
|
Answer» Correct option is (a) http The explanation is: For a URL to be accessed from remote location http protocol must be used. |
|
| 123. |
Which of these class is not a member class of java.io package?(a) String(b) StringReader(c) Writer(d) File |
|
Answer» Correct choice is (a) String Explanation: None. |
|
| 124. |
How can a protected modifier be accessed?(a) accessible only within the class(b) accessible only within package(c) accessible within package and outside the package but through inheritance only(d) accessible by all |
|
Answer» The correct choice is (c) accessible within package and outside the package but through inheritance only To explain I would say: The protected access modifier is accessible within package and outside the package but only through inheritance. The protected access modifier can be used with data member, method and constructor. It cannot be applied in the class. |
|
| 125. |
Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?(a) transient(b) volatile(c) global(d) No modifier is needed |
|
Answer» The correct option is (b) volatile Easiest explanation: The volatile modifier tells the compiler that the variable modified by volatile can be changed unexpectedly by other part of the program. Specially used in situations involving multithreading. |
|
| 126. |
MouseEvent is subclass of which of these classes?(a) ComponentEvent(b) ContainerEvent(c) ItemEvent(d) InputEvent |
|
Answer» Correct option is (d) InputEvent Best explanation: None. |
|
| 127. |
Which of these methods are used to find a URL from the cache of httpd?(a) findfromCache()(b) findFromCache()(c) serveFromCache()(d) getFromCache() |
|
Answer» The correct option is (c) serveFromCache() To explain I would say: serveFromCatche() is a boolean method that attempts to find a particular URL in the cache. If it is successful then the content of that cache entry are written to the client, otherwise it returns false. |
|
| 128. |
Application is instance of which class?(a) javax.servlet.Application(b) javax.servlet.HttpContext(c) javax.servlet.Context(d) javax.servlet.ServletContext |
|
Answer» Correct answer is (d) javax.servlet.ServletContext To explain I would say: Application object is wrapper around the ServletContext object and it is an instance of a javax.servlet.ServletContext object. |
|
| 129. |
Which of these interfaces define four methods?(a) ComponentListener(b) ContainerListener(c) ActionListener(d) InputListener |
|
Answer» Right answer is (a) ComponentListener Explanation: ComponentListener defines four methods componentResized(), componentMoved(), componentShown() and componentHidden(). |
|
| 130. |
Which of the following methods is a method of wrapper Integer for obtaining hash code for the invoking object?(a) int hash()(b) int hashcode()(c) int hashCode()(d) Integer hashcode() |
|
Answer» Correct option is (c) int hashCode() To explain I would say: None. |
|
| 131. |
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?(a) Public(b) Protected(c) No Modifier(d) All of the mentioned |
|
Answer» Correct option is (d) All of the mentioned For explanation: Either we can use public, protected or we can name the class without any specifier. |
|
| 132. |
If super class and subclass have same variable name, which keyword should be used to use super class?(a) super(b) this(c) upper(d) classname |
|
Answer» Correct answer is (a) super For explanation I would say: Super keyword is used to access hidden super class variable in subclass. |
|
| 133. |
Which of these is an instance variable of class httpd?(a) port(b) cache(c) log(d) All of the mentioned |
|
Answer» The correct choice is (d) All of the mentioned To explain: There are 5 instance variables: port, docRoot, log, cache and stopFlag. All of them are private. |
|
| 134. |
What type of variable can be defined in an interface?(a) public static(b) private final(c) public final(d) static final |
|
Answer» Correct option is (d) static final To explain: variable defined in an interface is implicitly final and static. They are usually written in capital letters. |
|
| 135. |
What happens when we access the same variable defined in two interfaces implemented by the same class?(a) Compilation failure(b) Runtime Exception(c) The JVM is not able to identify the correct variable(d) The interfaceName.variableName needs to be defined |
|
Answer» Right option is (d) The interfaceName.variableName needs to be defined Easy explanation: The JVM needs to distinctly know which value of variable it needs to use. To avoid confusion to the JVM interfaceName.variableName is mandatory. |
|
| 136. |
In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?(a) Protected(b) Private(c) Public(d) Static |
|
Answer» The correct answer is (b) Private Explanation: By declaring variable private, the variable will not be available in inherited to subclass. |
|
| 137. |
Which of these method returns the remainder of dividend / divisor?(a) remainder()(b) getRemainder()(c) CSIremainder()(d) IEEEremainder() |
|
Answer» The correct choice is (d) IEEEremainder() Explanation: IEEEremainder() returns the remainder of dividend / divisor. |
|
| 138. |
Which of these methods of Byte wrapper can be used to obtain Byte object from a string?(a) toString()(b) getString()(c) decode()(d) encode() |
|
Answer» Right option is (c) decode() Explanation: decode() methods returns a Byte object that contains the value specified by string. |
|
| 139. |
Which capturing group can represent the entire expression?(a) group *(b) group 0(c) group * or group 0(d) None of the mentioned |
|
Answer» Correct option is (b) group 0 The best explanation: Group 0 is a special group which represents the entire expression. |
|
| 140. |
Standard output variable ‘out’ is defined in which class?(a) Void(b) Process(c) Runtime(d) System |
|
Answer» Right answer is (d) System To explain I would say: Standard output variable ‘out’ is defined in System class. out is usually used in print statement i:e System.out.print(). |
|
| 141. |
Which of the following is the correct way of importing an entire package ‘pkg’?(a) import pkg.(b) Import pkg.(c) import pkg.*(d) Import pkg.* |
|
Answer» Right choice is (c) import pkg.* For explanation I would say: Operator * is used to import the entire package. |
|
| 142. |
Which of these class is a superclass of all other classes?(a) Math(b) Process(c) System(d) Object |
|
Answer» The correct answer is (d) Object Best explanation: The object class class is a superclass of all other classes. |
|
| 143. |
How to read entire file in one line using java 8?(a) Files.readAllLines()(b) Files.read()(c) Files.readFile()(d) Files.lines() |
|
Answer» Correct answer is (a) Files.readAllLines() The best explanation: Java 8 provides Files.readAllLines() which allows us to read entire file in one task. We do not need to worry about readers and writers. |
|
| 144. |
Which of these method returns a largest whole number less than or equal to variable X?(a) double ceil(double X)(b) double floor(double X)(c) double max(double X)(d) double min(double X) |
|
Answer» The correct choice is (b) double floor(double X) Best explanation: double floor(double X) returns a largest whole number less than or equal to variable X. |
|
| 145. |
Which of these class provides various types of rounding functions?(a) Math(b) Process(c) System(d) Object |
|
Answer» The correct choice is (a) Math The best explanation: None. |
|
| 146. |
Which of these class can encapsulate an entire executing program?(a) Void(b) Process(c) Runtime(d) System |
|
Answer» The correct choice is (b) Process Easy explanation: None. |
|
| 147. |
Which of these methods return a smallest whole number greater than or equal to variable X?(a) double ceil(double X)(b) double floor(double X)(c) double max(double X)(d) double min(double X) |
|
Answer» The correct answer is (a) double ceil(double X) Explanation: ceil(double X) returns the smallest whole number greater than or equal to variable X. |
|
| 148. |
Which of these classes encapsulate runtime environment?(a) Class(b) System(c) Runtime(d) ClassLoader |
|
Answer» The correct answer is (c) Runtime Easiest explanation: None. |
|
| 149. |
What is true about Class.getInstance()?(a) Class.getInstance calls the constructor(b) Class.getInstance is same as new operator(c) Class.getInstance needs to have matching constructor(d) Class.getInstance creates object if class does not have any constructor |
|
Answer» The correct answer is (d) Class.getInstance creates object if class does not have any constructor The explanation is: Class class provides list of methods for use like getInstance(). |
|
| 150. |
Which of these methods return a class object given its name?(a) getClass()(b) findClass()(c) getSystemClass()(d) findSystemClass() |
|
Answer» Correct choice is (d) findSystemClass() Easiest explanation: findSystemClass() returns a class object given its name. |
|