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 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?

View Answers









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
doubt about J2EE connetivity
doubt about J2EE connetivity  steps to connect J2EE components with MYSQL
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 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
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
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
DOUBT ?
DOUBT ?  in c++ member function of a class must be public
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
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
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
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  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
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
ModuleNotFoundError: No module named 'superClass'
ModuleNotFoundError: No module named 'superClass'  Hi, My Python... 'superClass' How to remove the ModuleNotFoundError: No module named 'superClass' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'superClass'
ModuleNotFoundError: No module named 'superClass'  Hi, My Python... 'superClass' How to remove the ModuleNotFoundError: No module named 'superClass' error? Thanks   Hi, In your python environment you
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
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
Version of reference>reference dependency
List of Version of reference>reference dependency
Java interface reference
Java interface reference  When can an object reference be cast to an interface reference
Inheritance in Java with example
a superclass/parentclass to a subclass. Interface in java is used for class... packages Subclass cannot inherit the default members of the superclass.... subclass can extend only single superclass Simple inheritance: The simple
PHP Call By Reference
PHP Call By Reference: In PHP we can pass reference of a variable, so that we... values from where we have sent. It is much like the call by reference, in which we... function. PHP Call By Reference Example:ADS_TO_REPLACE_1 <?php function
ModuleNotFoundError: No module named 'subclass-register'
ModuleNotFoundError: No module named 'subclass-register'  Hi, My... named 'subclass-register' How to remove the ModuleNotFoundError: No module named 'subclass-register' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'subclass-register'
ModuleNotFoundError: No module named 'subclass-register'  Hi, My... named 'subclass-register' How to remove the ModuleNotFoundError: No module named 'subclass-register' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'init_subclass'
ModuleNotFoundError: No module named 'init_subclass'  Hi, My... 'init_subclass' How to remove the ModuleNotFoundError: No module named 'init_subclass' error? Thanks   Hi, In your python
object
object  is it possible to create object in the same class..?.   Yes, you can. class CreateObject { CreateObject(){ System.out.println("I have an object."); } public static void main(String[] args
Validation doubt
Validation doubt  hi..... thanks for the other validation code. I have got that and implemented in my code but i have a doubt in that. As we try... think i am able to tell u what i want to and u have got whats my doubt. plz give
The ref in Spring, Reference Injection
Reference Injection In the reference injection one bean definition is injected to another. For reference injection you use the constructor-arg or property... into the second bean definition by reference using the property element's ref
doubt
doubt
doubt
Doubt
DOUBT
doubt
Identify correct and incorrect statements or examples about an entity bean's primary key and object identity.
and incorrect statements or examples about an entity bean's primary key and object... Identify correct and incorrect statements or examples about an entity bean's primary key and object identity. Prev Chapter 8
How to implement a superclass Person? - Java Beginners
How to implement a superclass Person?  How to implement a superclass..., write a program name TestQ2 that instantiates an object of each of these classes and invokes the toString() method of each of these object. how
Java reference
Java reference  What is weak reference in Java
by value or by reference
by value or by reference  Are objects passed by value or by reference

Ads