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 default execution method in java?
What is a string token?
What method is used to know the status of Checkbox(i.e it is checked or unchecked)?
i would like to attend for an interview of datalab technologies company i want to know the pattern of imnterview.
33. try { 34. // some code here 35. } catch (NullPointerException e1) { 36. System.out.print(”a”); 37. } catch (RuntimeException e2) { 38. System.out.print(”b”); 39. } finally { 40. System.out.print(”c”); 41. } What is the result if a NullPointerException occurs on line 34? 1 c 2 a 3 ab 4 ac
What is the right data type to represent a price in java?
What is java command?
How many ways can we create singleton class?
what is difference between colection and collections?
25 Answers Amdocs, IBM, Infosys, Ipog Software, Polaris, Tech Mahindra,
What is finalize()?
Why cant we define System.out.println() inside a class directly?
What's the base class of all exception classes?