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 are some characteristics of interference class?

0 Answers  


What is role of void keyword in declaring functions?

0 Answers   Adobe,


How a class can implement an interface?

5 Answers   SysArc,


What is java reflection?

0 Answers  


Why sleep()is in Thread and wait() in Object class? Why can't I have both in one class or vice versa?

1 Answers  






What is finally and finalize in java?

0 Answers  


Hi i am creating desktop application in that i want calling to mobile number. i have java telephone api (JTAPI) but i dont understand how it configure & use plese help me

0 Answers  


Why do we create threads in java?

0 Answers  


What is the difference between the final method and abstract method?

0 Answers  


Explain about the performance aspects of core java?

0 Answers  


I declared main() method as private. But it still running and displaying the output. Please Answer it . Code Snippet as Below: import java.io.*; class over { private static void main(String[] args) { int high = Integer.MAX_VALUE; int overflow = high + 1; int low = Integer.MIN_VALUE; int underflow = low - 1; System.out.println(high + "\n" +overflow +"\n"+ low +"\n"+underflow); //System.out.println(overflow); //System.out.println(low); //System.out.println(underflow); } }

4 Answers   Cap Gemini,


explain different ways of using thread? : Java thread

0 Answers  


Categories