write a simple program inheritance?

Answers were Sorted based on User's Feedback



write a simple program inheritance?..

Answer / prashant khot

class A
{

}
class B extends A
{
public static void main(String args[])
{
B b = new B();

}
}
In the above example, B is the class extending the A class.
Means that B is inherited from A.

Is This Answer Correct ?    26 Yes 2 No

write a simple program inheritance?..

Answer / dhawal

class A
{
int a=10;
}
class B extend A
{
public static void main(String[] a)
{
B objB;
objB=new A();
System.out.println("Value of a is"+objB.a);
}
}

Is This Answer Correct ?    2 Yes 13 No

Post New Answer

More Core Java Interview Questions

What is data type in computer?

0 Answers  


Why should we use singleton pattern instead of static class?

0 Answers  


Do I need java on my pc?

0 Answers  


Is java good for beginners?

0 Answers  


What is thread synchronization in java?

0 Answers  






we cannot create an object of interface but we can create a variable of it

1 Answers  


Who developed JScript language?

3 Answers  


What is the importance of static variable?

0 Answers  


what is finalmethod & final variable with example?

6 Answers   HP,


What is static and final keyword in java?

0 Answers  


What is factor r?

0 Answers  


Why string is a class?

0 Answers  


Categories