OOP
Where does the system stores parameters and local variables whenever a method is invoked? A. Heap B. Stack C. Array D. Tree
B. Stack
Which of the following exception is thrown when divided by zero statement is executed? A. NullPointerException B. NumberFormatException C. ArithmeticException D. None
C. ArithmeticException
Identify the infinite loop. A. for(;;) B. for(int i=0; i<1; i--) C. for(int i=0; ; i++) D. All of the above
D. All of the above
Identify the interface which is used to declare core methods in java? A. Comparator B. EventListener C. Set D. Collection
D. Collection
Identify the modifier which cannot be used for constructor. A. public B. protected C. private D. static
D. Static
Identify the prototype of the default constructor. Public class Solution {} A. Solution(void) B. Solution() C. public Solution(void) D. public Solution()
D. public Solution()
What is true about do statement? a) do statement executes the code of a loop at least once b) do statement does not get execute if condition is not matched in the first iteration c) do statement checks the condition at the beginning of the loop d) do statement executes the code more than once always
a) do statement executes the code of a loop at least once
Which of the following loops will execute the body of loop even when condition controlling the loop is initially false? a) do-while b) while c) for d) none of the mentioned
a) do-while
1. Which of the following is not a valid flow control statement? a) exit() b) break c) continue d) return
a) exit()
1. Which method can be defined only once in a program? a) main method b) finalize method c) static method d) private method
a) main method
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
a) super
Which of these keywords must be used to monitor for exceptions? a) try b) finally c) throw d) catch
a) try
What is true about a break? a) Break stops the execution of entire program b) Break halts the execution and forces the control out of the loop c) Break forces the control out of the loop and starts the execution of next iteration d) Break halts the execution of the loop for certain time frame
b) Break halts the execution and forces the control out of the loop
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. a) Runtime error b) Compile time error c) Code runs successfully d) First called method is executed successfully
b) Compile time error
What is not type of inheritance? a) Single inheritance b) Double inheritance c) Hierarchical inheritance d) Multiple inheritance
b) Double inheritance
Abstract class cannot have a constructor a) True b) False
b) False
Static members are not inherited to subclass. a) True b) False
b) False
The while loop repeats a set of code while the condition is not met? a) True b) False
b) False
1. What is the process of defining more than one method in a class differentiated by method signature? a) Function overriding b) Function overloading c) Function doubling d) None of the mentioned
b) Function overloading
What is true about constructor? a) It can contain return type b) It can take any number of parameters c) It can have any non access modifiers d) Constructor cannot throw an exception
b) It can take any number of parameters
1. Which component is used to compile, debug and execute java program? a) JVM b) JDK c) JIT d) JRE
b) JDK
1. Which exception is thrown when java is out of memory? a) MemoryError b) OutOfMemoryError c) MemoryOutOfBoundsException d) MemoryFullException
b) OutOfMemoryError
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
b) Private
What is true about protected constructor? a) Protected constructor can be called directly b) Protected constructor can only be called using super() c) Protected constructor can be used outside package d) protected constructor can be instantiated even if child is in a different package
b) Protected constructor can only be called using super()
Which one of the following is not a Java feature? a) Object-oriented b) Use of pointers c) Portable d) Dynamic and Extensible
b) Use of pointers
1. Which one of the following is not an access modifier? a) Protected b) Void c) Public d) Private
b) Void
1. Which of the following is not a valid jump statement? a) break b) goto c) continue d) return
b) goto
A class member declared protected becomes a member of subclass of which type? a) public member b) private member c) protected member d) static member
b) private member
Which of these selection statements test only for equality? a) if b) switch c) if & switch d) none of the mentioned
b) switch
Which of this statement is incorrect? a) switch statement is more efficient than a set of nested ifs b) two case constants in the same switch can have identical values c) switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression d) it is possible to create a nested switch statements
b) two case constants in the same switch can have identical values
1. What is the extension of compiled java classes? a) .txt b) .js c) .class d) .java
c) .class
1. Which of the following is not an OOPS concept in Java? a) Polymorphism b) Inheritance c) Compilation d) Encapsulation
c) Compilation
What is false about constructor? a) Constructors cannot be synchronized in Java b) Java does not provide default copy constructor c) Constructor can have a return type d) "this" and "super" can be used in a constructor
c) Constructor can have a return type
Which of these statements are incorrect? a) Equal to operator has least precedence b) Brackets () have highest precedence c) Division operator, /, has higher precedence than multiplication operator d) Addition operator, +, and subtraction operator have equal precedence
c) Division operator, /, has higher precedence than multiplication operator
1. Which component is used to compile, debug and execute the java programs? a) JRE b) JIT c) JDK d) JVM
c) JDK
1. Which of the following is a superclass of every class in Java? a) ArrayList b) Abstract class c) Object class d) String
c) Object class
1. Which of the following is used with the switch statement? a) Continue b) Exit c) break d) do
c) break
Which of these is correct way of inheriting class A by class B? a) class B + class A {} b) class B inherits class A {} c) class B extends A {} d) class B extends class A {}
c) class B extends A {}
What would be the behaviour if this() and super() used in a method? a) Runtime error b) Throws exception c) compile time error d) Runs successfully
c) compile time error
Which of the following is used for implementing inheritance through class? a) inherited b) using c) extends d) implements
c) extends
Which of these keywords is used to define interfaces in Java? a) intf b) Intf c) interface d) Interface
c) interface
1. Which of these cannot be used for a variable name in Java? a) identifier & keyword b) identifier c) keyword d) none of the mentioned
c) keyword
Which of these keywords is used to manually throw an exception? a) try b) finally c) throw d) catch
c) throw
Which of these keywords is not a part of exception handling? a) try b) finally c) thrown d) catch
c) thrown
1. What is the extension of java code files? a) .js b) .txt c) .class d) .java
d) .java
1. Which of this statement is incorrect? a) All object of a class are allotted memory for the all the variables defined in the class b) If a function is defined public it can be accessed by object of other class by inheritation c) main() method must be made public d) All object of a class are allotted memory for the methods defined in the class
d) All object of a class are allotted memory for the methods defined in the class
1. From where break statement causes an exit? a) Only from innermost loop b) Terminates a program c) Only from innermost switch d) From innermost loops or switches
d) From innermost loops or switches
1. Which environment variable is used to set the java path? a) MAVEN_Path b) JavaPATH c) JAVA d) JAVA_HOME
d) JAVA_HOME
1. Which component is responsible to run java program? a) JVM b) JDK c) JIT d) JRE
d) JRE
1. Which statement is true about Java? a) Java is a sequence-dependent programming language b) Java is a code dependent programming language c) Java is a platform-dependent programming language d) Java is a platform-independent programming language
d) Java is a platform-independent programming language
What is not the use of "this" keyword in Java? a) Passing itself to another method b) Calling another constructor in constructor chaining c) Referring to the instance variable when local variable has the same name d) Passing itself to method of the same class
d) Passing itself to method of the same class
Which of these keywords must be used to handle the exception thrown by try block in some rational manner? a) try b) finally c) throw d) catch
d) catch
1. Which of the following is a method having same name as that of it's class? a) finalize b) delete c) class d) constructor
d) constructor
Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration? a) break b) return c) exit d) continue
d) continue
1. Which of the following is not a decision making statement? a) if b) if-else c) switch d) do-while
d) do-while
Which of this keyword must be used to inherit a class? a) super b) this c) extent d) extends
d) extends
1. Which of these are selection statements in Java? a) break b) continue c) for() d) if()
d) if()
Which of the following is used for implementing inheritance through an interface? a) inherited b) using c) extends d) implements
d) implements
All classes in Java are inherited from which class? a) java.lang.class b) java.class.inherited c) java.class.object d) java.lang.Object
d) java.lang.Object
Which of these keywords are used for the block to be examined for exceptions? a) check b) throw c) catch d) try
d) try
1. Which of the following statements are true about finalize() method? A. It can be called Zero or one times B. It can be called Zero or more times C. It can be called exactly once D. It can be called one or more times
A. It can be called Zero or one times
Exception created by try block is caught in which block A. catch B. throw C. final D. none
A. catch
1. Where is System class defined? A. java.lang.package B. java.util.package C. java.io.package D. None
A. java.lang.package
What is the implicit return type of constructor? A. No return type B. A class object in which it is defined C. Void D. None
B. A class object in which it is defined
What is the variables declared in a class for the use of all methods of the class called? A. Object B. Instance variable C. Reference variable D. None
B. Instance variable
Which of the following statements is correct? a) Public method is accessible to all other classes in the hierarchy b) Public method is accessible only to subclasses of its parent class c) Public method can only be called by object of its class d) Public method can be accessed by calling object of the public class
a) Public method is accessible to all other classes in the hierarchy
When does Exceptions in Java arises in code sequence? a) Run Time b) Compilation Time c) Can Occur Any Time d) None of the mentioned
a) Run Time
Does Java support multiple level inheritance? a) True b) False
a) True
Which of these keywords is used to make a class? a) class b) struct c) int d) none of the mentioned
a) class
Which of these have highest precedence? a) () b) ++ c) * d) >>
a) ()
Which of the following is a valid declaration of an object of class Box? a) Box obj = new Box(); b) Box obj = new Box; c) obj = new Box(); d) new Box obj;
a) Box obj = new Box();
What would be behaviour if the constructor has a return type? a) Compilation error b) Runtime error c) Compilation and runs successfully d) Only String return type is allowed
a) Compilation error
Which of these statement is incorrect? a) Every class must contain a main() method b) Applets do not require a main() method at all c) There can be only one main() method in a program d) main() method must be made public
a) Every class must contain a main() method
Using which of the following, multiple inheritance in Java can be implemented? a) Interfaces b) Multithreading c) Protected methods d) Private methods
a) Interfaces
1. Which component is responsible for converting bytecode into machine specific code? a) JVM b) JDK c) JIT d) JRE
a) JVM
What is true about private constructor? a) Private constructor ensures only one instance of a class exist at any point of time b) Private constructor ensures multiple instances of a class exist at any point of time c) Private constructor eases the instantiation of a class d) Private constructor allows creating objects in other classes
a) Private constructor ensures only one instance of a class exist at any point of time