Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions Java Inheritance Concept.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Anand KK
Java Inheritance Concept.
1 Answer(s)      2 years and 10 months ago
Posted in : Java Interview Questions


Yesterday i got confused with following question in an aptitude exam. Question:Class A,B,C have method named doit(). Class B extends Class A,Class C extends Class B.How will you call method doit() in Class A from Class C. ???? Options:1.super.doit()2.super.super.doit()3.A.this.doit()4.this.doit().

Is this a valid question?If so whats the answer?Is super.super a valid one.??? Regards, Anand


Advertisement
View Answers

March 6, 2012 at 5:37 PM


hi anand , what about the access modifier of the method ,also super.super is not a valid one.i feel like the question itself is not clear. 1:super.doit() will invoke the classB doit() 2:super.super.doit(),compilation error 3:A.this.doit(),no idea..:) 4:this.doit();will invoke doit() in C

Sol:what i found is like ,u can put super.doit(); in B constructor and if u create the C object it will invoke A 's doit() ..,:)

Regards, yshak.



Related Tutorials/Questions & Answers:
Java Inheritance Concept.
Java Inheritance Concept.  Yesterday i got confused with following question in an aptitude exam. Question:Class A,B,C have method named doit(). Class B extends Class A,Class C extends Class B.How will you call method doit
Concept of Inheritance in Java
Concept of Inheritance in Java Concept of Inheritance in Java is considered... class from parent class. Let's understand the concept of inheritance in Java... to remember while using Inheritance concept in Java: members
Advertisements
Inheritance in Java 7
This tutorial describe concept of Inheritance. It is one of OOPs concept
Java : Multilevel Inheritance
Java : Multilevel Inheritance This section contains concept of multilevel Inheritance in java. Multilevel Inheritance : In multilevel inheritance more than... can say multilevel inheritance create one-to-one ladder. Now you can access
Inheritance,Inheritance in Java,Java Inheritance
; To know the concept of inheritance clearly you must have the idea of class and its... Programming. It is the concept that is used for reusability purpose. Inheritance... is used. To clearly understand the concept of inheritance you must go through
inheritance - Java Beginners
inheritance  help me on inheritance concept in java specialy on overloading and overridding concept
Inheritance in java - Java Beginners
Inheritance in java  I want a example program using the concept of (single and multiple) inheritance.  Hi Friend, Please visit the following link: http://www.roseindia.net/java/language/inheritance.shtml Thanks
Java inheritance
Java inheritance   can the child access protected content of the parent if the child is in a different project   If you have considered different project as different package then the child cannot access the content
Inheritance in java - Java Beginners
Inheritance in java  I want a example program using the concept of (simple and multiple) inheritance
Inheritance in java with example
Inheritance in java with example          Inheritance is one of the concept of the Object- Oriented programming. The advantage of using the inheritance
concept Understatnding problem - Java Beginners
concept Understatnding problem  Even though I have studied in detail inheritance & interfaces in java , I fail to understand "How Interfaces Help in Multiple Inheritance ?" . Pls. Supplement ur ans. with an example. Thanx
java inheritance
java inheritance  problem with following code.... class Employee { int empno; String name; String edesig; Employee() { empno=0; } Employee(int eno,String ename,String ed) { empno=eno; name=ename
java inheritance
java inheritance  ACME Bike shop has created a new scheme to reward employees for selling bicycles. Sales are only made by either, a sales person...% and to the sales agents at a rate of 10%. Write a Java application
Inheritance java Example
Inheritance java Example  How can we use inheritance in java program... for bread Description:- The above example demonstrates you the concept of inheritance. Inheritance is a way of establishing a subtype from an existing object
inheritance
inheritance  how does one implement inheritance in java
multiple inheritance - Java Beginners
multiple inheritance  Why java does not support Multiple Inheritance...)why java classes does not support Multiple Inheritance? JAVA CLASSES ONLY... Inheritance. Ans...>java classes doesn't support multiple inheritance,the practical
how can i achieve multiple inheritance in java without using inheritance ?
how can i achieve multiple inheritance in java without using inheritance ?  how can i achieve multiple inheritance in java without using inheritance
Inheritance program in java
in Java. The concept of inheritance is used to make the things from general to more...In this tutorial we will discuss examples of Simple Inheritance in Java and Multilevel Inheritance in Java. Inheritance is an OOPS (Object Oriented
Explain the concept of thread priorities in Java.
Explain the concept of thread priorities in Java.  Explain the concept of thread priorities in Java
Inheritance and Composition - Java Beginners
inheritance class TextDemo { int x; int y; int get(int p, int q...Inheritance and Composition  import java.util.*; public class... arrangement in the design of your solution. In an object-oriented design of a Java
Inheritance Overloading - Java Beginners
Inheritance Overloading  The problem is: I have this program: class Base{ int i = 1; int j = 2; Base(int i, int j){ i = i; j = j...://www.roseindia.net/java/beginners/constructoroverloading.shtml
Exp.4 Write any C++ programs to demonstrate multiple inheritance concept of an object oriented programming.
Exp.4 Write any C++ programs to demonstrate multiple inheritance concept of an object oriented programming.  (Aim:- The main aim of this experiment...; Here is a code that demonstrates you the concept of multiple inheritance
Java Inheritance - Java Beginners
Java Inheritance  Since every object inherits from Object class, why the following statement is not true. Assuming the code tries to open a file then instead of using throws IOException why not use throws Object? import
Inheritance - Java Beginners
Inheritance  pls help me!!! Question: write an inheritance hierachy for classes Quadrilateral,Trapezoid,Parallelogram, Rectangle and Square. Use Quadrilateral as superclass. make hierachy as deep as possible. Specify
Inheritance - Java Beginners
of Inheritance within the java programming. class Points{ private double x... and set the center of thye base. THANKS SO MUCH. I am really a java beginner
Inheritance Example In Java
Inheritance Example In Java In this section we will read about the Inheritance... the Inheritance in Java the Multiple inheritance is not supported. This reduces... the inheritance feature in Java programming. This example will demonstrate you
Does Java support multiple inheritance?
Does Java support multiple inheritance?  Hi, Does Java support multiple inheritance? thanks   hi, Please visit the following link: http://www.roseindia.net/java/language/inheritance.shtml Hope
Java code to implement MULTIPATH INHERITANCE
Java code to implement MULTIPATH INHERITANCE  HI, I am new to java programming. I want to implement multipath inheritance in one java program...(Hierarchical and Multiple inheritance) Thanks in advance
Inheritance problem - Java Beginners
Inheritance problem  hello friend can u please help me that why this program is printing show method of Base_Class b=5 even though i am assigning the Base_Class object into the Super_Class reference i.e Super_Class bc=new
Inheritance and Composition - Java Beginners
Inheritance and Composition  import java.util.*; public class TestPet { public static void main(String[]kevs) { Scanner console=new Scanner(System.in); String type, name, home; int weight, years; char gender
Inheritance and Composition - Java Beginners
Inheritance and Composition  CAN YOU FIND THE ERROR OF MY CODE JAVA.THIS IS A TEST CLASS.I CANT FIND THE ERROR,CAN YOU FIX IT FRIEND.THANK YOU SO MUCH. import java.util.*; public class TestPet { public static void main
 

 

 

DMCA.com