Multiple Choice Question on Java
1. Which of the following option leads to the portability and security of Java?
Bytecode is executed by JVM
The applet makes the Java code secure and portable
Use of exception handling
Dynamic binding between objects
2. Which of the following is not a Java features?
Dynamic
Architecture Neutral
Use of pointers
Object-oriented
3. What will be the return type of a method that not returns any value?
void
int
double
None of the above
4. In which area of memory the system stores parameters and local variables whenever a method is
invoked?
Heap
Storage Area
Stack
Array
5. Which of the modifier can't be used for constructors?
public
private
static
protected
6. The variables declared in a class for the use of all methods of the class are called
reference variables
objects
instance variables
None of these
7. The finalize () method is called just prior to
An object, variable or method goes out of scope.
An object or variable goes out of scope.
Before garbage collection.
None of the above
8. Public class Test { }
What is the prototype of the default constructor?
public Test(void)
Test( )
Test(void)
public Test( )
9. In java arrays are
objects
object references
primitive data type
None of the above
10. Which one of the following is a valid statement?
char[] c = new char();
char[] c = new char[5];
char[] c = new char(4);
char[] c = new char[];
11. When you pass an array to a method, the method receives ________?
A copy of the array.
A copy of the first element.
The reference of the array.
The length of the array.
12. Which will legally declare, construct, and initialize an array?
int [] myList = {};
int [] myList = (5, 8, 2);
int myList [] [] = {4,9,7,0};
int myList [] = {4, 3, 7};
13. Which is true?
"X extends Y" is correct if and only if X is a class and Y is an interface.
"X extends Y" is correct if and only if X is an interface and Y is a class.
"X extends Y" is correct if X and Y are either both classes or both interfaces.
"X extends Y" is correct for all combinations of X and Y being classes and/or interfaces.
14. toString () methods is defined in?
java.lang.String
java.lang.Object
java.lang.util
None of these
15. The String method compareTo () returns
true
false
an int value
-1
16. How many Constructors String class have?
2
7
13
11
17. Which of the following declares an abstract method in an abstract Java class?
public abstract method();
public abstract void method();
public void abstract Method();
public abstract void method() {}
18. Which of the following statements regarding abstract classes are true?
An abstract class can be extended.
A subclass can override a concrete method in a superclass to declare it abstract.
An abstract class can be used as a data type.
All of the above
19. In Java, declaring a class abstract is useful?
To prevent developers from further extending the class.
When it doesn't make sense to have objects of that class.
When default implementations of some methods are not desirable.
To force developers to extend the class not to use its capabilities.
20. Runnable is a ___________
class
abstract class
interface
method
21. The class at the top of exception class hierarchy is _________
Arithmetic Exception
Throwable
Object
Exception
22. In which of the following package Exception class exist?
java.util
java.file
java.io
java.lang
23. Exception generated in try block is caught in __________ block.
catch
throw
throws
finally
24. Which of the following blocks execute compulsorily whether exception is caught or not.
finally
catch
throws
throw
25. What happen in case of multiple catch blocks?
Either super or subclass can be caught first.
The superclass exception must be caught first.
The superclass exception cannot caught first.
None of these