Q1) State true or false :
protected access is provided even to subclasses that reside in a different package from the class that owns this feature.
Q2) Which of the following are valid method declarations?
a] abstract native void method();
b] abstract void method(){}
c] public static final void method(){}
d] abstract public synchronized void method();
e] public void abstract method();
f] public abstract void method() throws ArithmeticException;
Q3)Which of the following are valid member variable declarations?
a] abstract int i;
b] final int i;
c] final volatile int i;
d] public transient final i
e] protected static final int i
Q4)Which of the following are true regarding interfaces?
a] All methods in an interface are coderanch,abstract and static
b] All interface methods should have public accessibility when implemented in class
c] All variables in an interface are coderanch,static and final
d] interfaces can have constructors
e] It is valid to declare the methods explicitly in an interface as static.
Q5)True or False
a] Default constructor is provided for all classes
b] Default constructor is provided for the class which does define any constructor.
Q6)What would be the possible output?
1.class SampleConstructor
2.{
3.public static void main(
String args[])
4. {
5. Parent p=new Parent(10);
6. Child c=new Child();
7.}
8.}
9.class Parent
10.{
11. public Parent(int i)
12. {
13. System.out.println("Value of i is "+i);
14. }
15.}
16.class Child extends Parent
17.{
18. public Child()
19. {
20. System.out.println("Constructor's do not have return type");
21 }
22}
a] compiles and runs with output Constructor's do not have return type
b] compiler error in line 18 prevents compilation
c] compiler error in line 11
d] compiles and runs with output Value of i is10
I am really confused.
Thanks in advance.
Bye.
21. Which of the following are invalid about constructors
a] constructors do not have return type
b] you cannot have more than one constructor in a class
c] To call a constructor defined in the superclass, you have to place the call as the first statement in the
calling constructor