On Java | More Q&A Click Here
# | Question | Options | Answer |
---|---|---|---|
101 | In order to restrict a variable of a class from inheriting to subclass, how variable should be declared? | Private | |
102 | All classes in Java are inherited from which class? | java.lang.Object | |
103 | Using which of the following, multiple inheritance in Java can be implemented? | Interfaces | |
104 | Which of this keyword must be used to inherit a class? | extends | |
105 | Which of these is supported by method overriding in Java? | Polymorphism | |
106 | If a class inheriting an abstract class does not define all of its function then it will be known as? | Abstract | |
107 | Which of these is not abstract? | Thread | |
108 | Which of this package is used for handling security related issues in a program? | java.security | |
109 | Which of these methods can randomize all elements in a list? | shuffle() | |
110 | Which of these must contain a unique element? | Set | |
111 | Which of these interface handle sequences? | List | |
112 | Which of these is a method of ListIterator used to obtain index of previous element? | previousIndex() | |
113 | Which of these methods can be used to move to next element in a collection? | next() | |
114 | Which of these return type of hasNext() method of an iterator? | Boolean | |
115 | What is Collection in Java? | A group of objects | |
116 | Which of these methods deletes all the elements from invoking collection? | clear() | |
117 | Which of these classes is not part of Java’s collection framework? | Maps | |
118 | Which of these packages contain all the collection classes? | java.util | |
119 | Which of these methods is used to retrieve the elements in properties object at specific location? | getProperty() | |
120 | Which of these method is used to insert value and its key? | put() | |
121 | Which of these class object uses the key to store value? | All of above | |
122 | Which of these methods is used to add elements in vector at specific location? | addElement() | |
123 | Which of these are legacy classes? | All of Above | |
124 | Which of these methods can be used to obtain set of all keys in a map? | keySet() | |
125 | Which of these method is used to remove all keys/values pair from the invoking map? | remove() | |
126 | Which of the following is not OOPS concept in Java? | Compilation | |
127 | Which of the following is a type of polymorphism in Java? | Compile time polymorphism | |
128 | When does method overloading is determined? | At compile time | |
129 | When Overloading does not occur? | More than one method with same name, same number of parameters and type but different signature | |
130 | Which concept of Java is a way of converting real world objects in terms of class? | Abstraction | |
131 | Which concept of Java is achieved by combining methods and attribute into a class? | Encapsulation | |
132 | What is it called if an object has its own lifecycle and there is no owner? | Association | |
133 | What is it called where child object gets killed if parent object is killed? | Composition | |
134 | What is it called where object has its own lifecycle and child object cannot belong to another parent object? | Aggregation | |
135 | Method overriding is combination of inheritance and polymorphism? | True | |
136 | What is the stored in the object obj in following lines of Java code? -> box obj; | NULL | |
137 | Which of these keywords is used to make a class? | class | |
138 | Which of the following is a valid declaration of an object of class Box? | Box obj = new Box(); | |
139 | Which of these statement is incorrect? | Every class must contain a main() method | |
140 | Which of the following statements is correct? | Public method is accessible to all other classes in the hierarchy | |
141 | What is the return type of a method that does not return any value? | void | |
142 | Which of the following is a method having same name as that of it’s class? | constructor | |
143 | Which method can be defined only once in a program? | main method | |
144 | Which of this statement is incorrect? | All object of a class are allotted memory for the methods defined in the class | |
145 | What is the return type of Constructors? | none of the mentioned | |
146 | Which keyword is used by the method to refer to the object that invoked it? | this | |
147 | Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed? | none of the mentioned | |
148 | Which function is used to perform some action when the object is to be destroyed? | finalize() | |
149 | Which of the following statements are incorrect? | finalize() method is called when a object goes out of scope and is no longer needed | |
150 | What is true about private constructor? | Private constructor ensures only one instance of a class exist at any point of time | |
151 | What would be the behaviour if this() and super() used in a method? | compile time error | |
152 | What is false about constructor? | Constructor can have a return type | |
153 | What is true about Class.getInstance()? | Class.getInstance creates object if class does not have any constructor | |
154 | What is true about protected constructor? | Protected constructor can only be called using super() | |
155 | What is not the use of this keyword in Java? | Passing itself to method of the same class | |
156 | What would be the behaviour if one parameterized constructor is explicitly defined? | Compilation succeeds but at the time of creating object using default constructor, it throws compilation error | |
157 | What would be behaviour if the constructor has a return type? | Compilation error | |
158 | What is the process of defining two or more methods within same class that have same name but different parameters declaration? | method overloading | |
159 | Which of these can be overloaded? | All of the mentioned | |
160 | Which of these is correct about passing an argument by call-by-value process? | Copy of argument is made into the formal parameter of the subroutine | |
161 | What is the process of defining a method in terms of itself, that is a method that calls itself? | Recursion | |
162 | Which of these access specifiers must be used for main() method? | public | |
163 | Which of these is used to access a member of class before object of that class is created? | static | |
164 | Which of these is used as a default for a member of a class if no access specifier is used for it? | private | |
165 | What is the process by which we can control what parts of a program can access the members of a class? | Encapsulation | |
166 | Which of the following statements are incorrect? | private members of class can be inherited by a subclass, and become protected members in subclass | |
167 | Which of these access specifier must be used for class so that it can be inherited by another subclass? | public | |
168 | Which one of the following is not an access modifier? | Void | |
169 | All the variables of class should be ideally declared as? | private | |
170 | Which of the following modifier means a particular variable cannot be accessed within the package? | private | |
171 | How can a protected modifier be accessed? | accessible within package and outside the package but through inheritance only | |
172 | What happens if constructor of class A is made private? | Objects of class A can be instantiated only within the class where it is declared | |
173 | All the variables of interface should be? | public, static and final | |
174 | What is true of final class? | Final class cannot be inherited | |
175 | How many copies of static and class variables are created when 10 objects are created of a class? | 1, 10 | |
176 | Which is the modifier when there is none mentioned explicitly? | default | |
177 | String in Java is a? | class | |
178 | Which of these method of String class is used to obtain character at specified index? | charAt() | |
179 | Which of these keywords is used to refer to member of base class from a subclass? | super | |
180 | Which of these method of String class can be used to test to strings for equality? | equals() | |
181 | Which of the following statements are incorrect? | Strings in java are mutable | |
182 | Which of this keyword can be used in a subclass to call the constructor of superclass? | super | |
183 | What is the process of defining a method in a subclass having same name & type signature as a method in its superclass? | Method overriding | |
184 | Which of these keywords can be used to prevent Method overriding? | final | |
185 | Which of these is supported by method overriding in Java? | Polymorphism | |
186 | What is not type of inheritance? | Double inheritance | |
187 | Using which of the following, multiple inheritance in Java can be implemented? | Interfaces | |
188 | All classes in Java are inherited from which class? | java.lang.Object | |
189 | In order to restrict a variable of a class from inheriting to subclass, how variable should be declared? | Private | |
190 | If super class and subclass have same variable name, which keyword should be used to use super class? | super | |
191 | Static members are not inherited to subclass. | True | |
192 | Which of the following is used for implementing inheritance through an interface? | implements | |
193 | Which of the following is used for implementing inheritance through class? | extends | |
194 | What would be the result if a class extends two interfaces and both have a method with same name and signature? Lets assume that the class is not implementing that method. | Compile time error | |
195 | Which of these class is superclass of every class in Java? | Object class | |
196 | Which of these method of Object class can clone an object? | Object clone() | |
197 | Which of these method of Object class is used to obtain class of an object at run time? | Class getclass() | |
198 | Which of these keywords can be used to prevent inheritance of a class? | final | |
199 | Which of these keywords cannot be used for a class which has been declared final? | abstract | |
200 | Which of these class relies upon its subclasses for complete implementation of its methods? | abstract class |