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



Home Answers Viewqa Java-Beginners doubt about superclass reference and subclass object

Have Programming Question? Ask it here!
 
 
 


ravinder sangwan
doubt about superclass reference and subclass object
0 Answer(s)      2 years and 2 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?


Advertisement
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
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
Advertisements
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 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 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
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
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
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 this
doubt this  what is the use of "this" and "super" keyword
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
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
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
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
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
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
Reference Data Types
In this section we will discuss about Reference Data Types in Java 7
How to access Subclass?
How to access Subclass?  How to access subclass in java? please tell me the syntex with an example
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
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: <?php function swap(&
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
by value or by reference
by value or by reference  Are objects passed by value or by reference
Java reference
Java reference  What is weak reference in Java
Tiny Window with subclass
Java NotesExample - Tiny Window with subclass This is a reimplementation... by defining a subclass of JFrame. All the work of buiding the JFrame will be put... program and one containing the JFrame subclass. It's perhaps more common
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
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
appdelegate reference
appdelegate reference  Hi, How to get the reference of appdelegate in my view controller class. Thanks.   Hello Friend, Following code example show how to get appdelegate reference anywhere in your iPhone/iPad
cross reference
cross reference   hi everbody as i got a problem and i have no idea the problem that i need to create a cross reference map for a Java source file... generation of the cross-reference map. Finally, the cross-reference map is output
How to implement this superclass Person - Java Beginners
How to implement this superclass Person  how to Implement a superclass Person which it need to Make two classes, Student and Instructor, that inherit from Person. A person has a name and a year of birth. A student has a major
pointer to a reference
pointer to a reference  pointer to a reference in C++    #include <iostream> using namespace std; void foo1(int& x) { int* p = &x; *p = 123; } void foo2(int* x) { int
pointer to a reference
pointer to a reference  pointer to a reference in C++    #include <iostream> using namespace std; void foo1(int& x) { int* p = &x; *p = 123; } void foo2(int* x) { int
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
a multithreaded program by creating a subclass of Thread
a multithreaded program by creating a subclass of Thread  I want The threads will execute the following output in the suitable interface. like this OUTPUT thread1: Java thread1: is thread2: Java thread1: an thread2
pass by value /reference - Java Beginners
pass by value /reference  hello sir/mam, i know pass by value is a primitive type in java. what about pass by reference in java ? .. For object type pass by value is used or pass by reference is used ? pls give me a example
 

 

 

DMCA.com