doubt about superclass reference and subclass object

Ads

 
 

Share on Google+Share on Google+

ravinder sangwan
doubt about superclass reference and subclass object
0 Answer(s)      5 years and 5 months ago
Posted in : Java Beginners
class superclass
{
p.bark()
}
class subclass extends superclass
{
p.bark
}
{p.s.v.m()
superclass refvar = new subclass();
p.bark();
}

Now my questions 1.Why is necessary for parent to have a method in this case whether child have it or not? i am told that at compile time as reference variable is of superclass so compiler checks for this method in superclass at compile time, correct me if i am wrong anywhere.... 2.when compiler reads p.bark() where does it go next (i know child method overrides but i want to know that first it goes to superclass method or subclass and WHY?) 3.why subclass needs to have a access modifier of wider scope?

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
doubt about superclass reference and subclass object
doubt about superclass reference and subclass object  class superclass { p.bark() } class subclass extends superclass { p.bark } {p.s.v.m() superclass refvar = new subclass(); p.bark(); } Now my questions 1.Why is necessary
PHP Object Reference
PHP Object and References: It is a very common misconception about object that the terms object and reference is interchangeable. Now we must know what is actually an object and what is a reference. Whenever an object is instantiated
Advertisements
Object reference not set to an instance of an object
Object reference not set to an instance of an object  Object reference not set to an instance of an object
doubt about J2EE connetivity
doubt about J2EE connetivity  steps to connect J2EE components with MYSQL
doubt about JMS selector
doubt about JMS selector  Hi! , i have a little problem with message selector in JMS api. I'am try develop a request and response with JMS queue, but I didn├?┬┤t get success. I use this reference site like guide. in my
doubt about JMS selector
doubt about JMS selector  Hi! , i have a little problem with message selector in JMS api. I'am try develop a request and response with JMS queue, but I didn├?┬┤t get success. in my case, i send a message to server, server
Doubt about Xstream Converter
Doubt about Xstream Converter  Hi, I am using the Xstream freamwork to read a lot of files in a batch operation. I use a custom converter Xstream to read some properties of my Xml file, but when I changed my application
Reference type Vs Object type. - Java Beginners
Reference type Vs Object type.  Can anyone explain the exact difference between Reference and Object, how can i create a reference ? When exactly..."); bookvar is not an object, it's a variable which contains a reference
JavaScript array object reference
JavaScript array object reference   ... that helps you in understanding JavaScript array object reference. For this we are using... ,we must use index. The document.write print the element in an array object
reference
reference  hi i have one doubt i wrote 2 classes student and person... Sample(main()) in that i create 2 objects. in that i want to store object reference of student into person can do like this or any other alternative Student
doubt this
doubt this  what is the use of "this" and "super" keyword
JAVA CLASSES/ SUPERCLASS
a subclass of Employee. A person has a name, address, phone number, and email address... another class contractWorker which is a subclass of class employee. Instantiate an object of class contractWorker and show how this object inherits behavior
DOUBT ?
DOUBT ?  in c++ member function of a class must be public
Super-class in java
through a superclass and subclass definition and achieved through the object creation... and subclass. -- Through inheritance a new class inherits some existing behavior and states of another class which is called as the superclass. This promotes
Doubt
Doubt  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details
doubt
doubt  why object oriented language is required in real time applications and Is java pure object oriented programming language and from where we can..., object oriented language is required in real time applications. Java is not pure
Doubt
User request form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
How to load page  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
Submit and process form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
Doubt
load next page after submitting  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
About Object cloning. - Java Interview Questions
About Object cloning.  what is Object cloning? can u explain with example?  Hi Friend, The way to make an identical copy of an object is said to be object cloning.In java, it has to be done using clone() method
This & Super reference
This & Super reference  If i want to call a subclass constructor & superclass constructor in a subclass parameterized constructor. Then which constructor call statement should be placed first? super() or this() And why
Reference Data Types
In this section we will discuss about Reference Data Types in Java 7
Using Super class Variables With Sub-classed Objects
of OOP in java is that, we can assign a subclass object or variable to the variable of the  superclass type. In this example we have a class named Rectangle which is the superclass of class Square, and Square is a superclass of Triangle. We
Exception handling in super and subclass while implementing inheritance,,?
Exception handling in super and subclass while implementing inheritance,,?  How to implement Superclass Exceptions with SubClass while implementing Inheritance concept in core java.? Please answer for this with sample code
How to access Subclass?
How to access Subclass?  How to access subclass in java? please tell me the syntex with an example
Version of reference>reference dependency
List of Version of reference>reference dependency
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how to integrate struts with hibernate,any predifined plugin is available or we need to create our own plugin????? and please help me. how to use dao s while integrating
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how to integrate struts with hibernate,any predifined plugin is available or we need to create our own plugin????? and please help me. how to use dao s while integrating
Inheritance in Java with example
. Inheritance is a Object Oriented Programming concepts, which allows to extend a superclass/parentclass to a subclass. Interface in java is used for class... features of a superclass into subclass in Multilevel inheritance. Example
Java interface reference
Java interface reference  When can an object reference be cast to an interface reference

Ads

 
Advertisement null

Ads