Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to call One constructor from another;

Answer Posted / tulasi prasad

We can call the parent class constructor from the child
class constructor.

class Parent
{
int a;
Parent(int x)
{
a=x;
}
}
class Child extends Parent
{
int b;
Child(int x,int y)
{
super(x);
b=y;
System.out.println(a);
System.out.println(b);
}
}

class Test
{
public static void main(String args[])
{
Child obj = new Child(1,2);
}
}

Is This Answer Correct ?    13 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is synchronization and why is it important in java programming?

883


What are the different http methods?

976


What is the difference between Java and C++?

1124


What is static import in java?

940


which pattern is default in scanner package?

2186


How do you declare a destructor in java?

929


How does list work in java?

864


What is a class instance variable?

1058


Define locale.

992


What is the benefit of using enum to declare a constant?

1039


Can a constructor be made final?

1050


What is the difference between the paint() and repaint() methods?

1009


How do I convert a string to an int in java?

1011


Can a private method of a superclass be declared within a subclass?

959


What does the string method compareto () do?

1009