In Inheritance if we are implementing Multi level inheritance
and all class having same name of variable and now i want to
access each class variable and how it is possible?
Answers were Sorted based on User's Feedback
Answer / megha
IF ClassC extends ClassB and ClassB extends ClassA
All Classes having "public int a " with different values,
then
ClassA objA = new ClassA();
ClassB objAB = new ClassB();
ClassC objAC = new ClassC();
System.out.println(objA.a);
System.out.println(objAB.a);
System.out.println(objAC.a);
will show each class variable individually
****************************O R *******************
make a method to return superclass variable using "super.a"
Is This Answer Correct ? | 4 Yes | 0 No |
What is the minimum and maximum length of an identifier?
Why set do not allow duplicates in java?
What are the methods to rectify ambiguities in the interfaces in JAVA?
They had given one progam final HashMap hm=new HashMap(); public void show() { hm.put("name",value); } in this prg here the final hashtable value can be changed in put method,its the prg run?
suppose string s1="rajnish"; string s2="bhaskar"; then what will be happend ?
Why main() method is public, static and void in java ?
When you say String is immutable, what do you mean by that? Say I have String s = "Ness" s= s+"Technologies"; What will happen? If the value gets appended, then what is the meaning of immutable here?
Is {a, n, d} a palindrome? If you are given a random string, is it a palindrome or not?
What is a concrete classes? Is Java object class is concrete class?
Can you make a constructor final?
How do you convert bytes to character in java?
Explain the difference between a Thread and a Process.