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 a numeric digit?

1047


Can you make a constructor final in Java?

1083


What is the difference between a loader and a compiler?

991


what is meant by encapsulation?

1047


What is Garbage Collection in Java

1043


Write a program to show whether a graph is a tree or not using adjacency matrix.

1050


Can I extend singleton class in java?

1055


Can a class have multiple superclasses?

1101


What is method overloading and method overriding?

1016


What does int [] mean in java?

992


What is java used for on a computer?

949


Can an anonymous class be declared as implementing an interface and extending a class in java programming?

1194


What is a line break?

984


What is string example?

1008


What is generics in java interview questions?

1020