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
Can we have a try block without catch block?
Do extraneous variables affect validity?
Explain java coding standards for methods?
How to create a fecelet view?
When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?
What does exclamation mean in java?
What is the set interface in java programming?
Why java is called not pure object oriented language?
Can we compare two strings in java?
Can we define package statement after import statement in java?
How many arguments can be passed to main ()?
How do you do absolute value in java?
Do you know how to reverse string in java?
Given a singly linked list, determine whether it contains a loop or not without using temporary space?
Write a function to find out longest palindrome in a given string?