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 unicode full form?

991


why an outer class cannot be declared as private?

4328


What does the ‘static’ keyword mean? Is it possible to override private or static method in java?

995


What is string substring?

1179


What is :: operator in java?

978


How to find the index of the largest number in an arraylist java?

1040


Does .length start 0 java?

1023


Is math an abstract class in java?

1022


What is the main use of java?

1176


what is mutual exclusion? : Java thread

1030


You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain

997


What is double parsedouble in java?

1058


What are the ways to instantiate the class class?

1106


What is the basic difference between string and stringbuffer object?

1094


What is meant by final class?

1125