Java Que Paper
Java Que Paper
Name :
Emp Id : Max. Marks : 25
3. What is the result of attempting to compile and execute the following classes
class GRC1 {public static void main(String[] args) {}} // 1
class GRC2 {protected static void main(String[] args) {}} // 2
class GRC3 {private static void main(String[] args) {}} // 3
a) Compile time error at line 2, 3
b) Can execute all the 3 classes
c) Only GRC1 can be executed
d) Compile time error at line 3 alone
4. Which of these does not belong to Java keywords
a) transient
b) serializable
c) synchronized
d) finally
e) finalize
class C
{
public static void main(String args[])
{
A a1 = new B();
a1.abc();
}
}
a) hi
b) hello
c) runtime error
d) compile time error
13. Which of these statements holds good for the default constructor
a) Default constructor is added by the JVM
b) Default constructor is added by the compiler
c) Default constructor is only created when there is no other constructor
available
d) Default constructor is always created regardless of any other constructor
14. Which of these task are performed by the JVM
a) Class Loading
b) Byte Code Verification
c) Execution of Bytecodes
d) All the above
Tester(int var)
{
this("hello");
}
Tester(String s)
{
this();
System.out.println(s);
}
Tester()
{
System.out.println("good-bye");
}
a) nothing
b) "hello"
c) 5
d) "hello" followed by "good-bye"
e) "good-bye" followed by "hello"
21. Which class should be extended to create a custom unchecked exception class
a) RuntimeException
b) Exception
c) ArithmeticException
d) NullPointerException
a) import java.awt.*;
package Mypackage;
class Myclass {}
b) package MyPackage;
import java.awt.*;
class MyClass{}
c) /*This is a comment */
package MyPackage;
import java.awt.*;
class MyClass{}
25. Which two of these statements are true about constructors? (Choose two.)
a. Constructors must not have arguments if the superclass constructor does not have
arguments.
b. Constructors are not inherited.
c. Constructors cannot be overloaded.
d. The first statement of every constructor is a legal call to the super() or t this()method.