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.