Great Deals

Puzzles about cobstructor

09:38 suresh chaudhari 0 Comments


Hi here I come again with puzzle about constructor.
As we know if we don't create constructor it is by default created .
But imagine a situation where you have created parameterized constructor??????
Let's take a look at following code snippet
Class A
{ A(int a){ }
}
Class B extends A
{
   }
class c extends B
{
  //Now imagine a situation where you need to call a parameterized constructor of A.
Probably you will choose
A a=new A(5);
}
Wait!!!!!!!!!!!!!!
I would like to take a stand and say no!!!.
Because if there is any parameterized constructor then you need to put default constructor manually.
So the redefination of class A goes like this
Class A
{ A(){
        }
   A(int a){
    }
}

0 comments:

Advertising