Santy Jagtap

Greenhorn
+ Follow
since Apr 06, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Santy Jagtap

generally bootestrap classes are loaded from jre's lib directory
so can we put our class file into that.
Not sure whether it 'll load using bootstrap classloader or system?
18 years ago
generally bootestrap classes are loaded from jre's lib directory
so can we put our class file into that.
Not sure whether it 'll load using bootstrap classloader or system?
18 years ago
Yes that was of gr8 help to me...
But just want to know is there any other way of doing the same?
18 years ago
Can we load a user defined class using bootstrap classloader?
18 years ago
Got the perfect answer the answer is as follows

whenever we access any private method or private variable of a particular class from the same class it will call the same class's private method only irrespective of inheritance.

for supporting my answer giving one example

class BAAP
{
protected void meth()
{
System.out.println("Baap");
}
public static void main(String[] args)
{
BAAP b = new BETA();
b.meth();
}
}
class BETA extends BAAP
{
//private void meth()
public void meth()
{
System.out.println("Beta");
}
}

meth method is overridden in BETA with higher access specifier so now as per inheritance rule (since meth of BETA is accessible)output would be : Beta
but since meth is private in BAAP the output will be : Baap

for more clarification just change the access specifiers of both the method as public and observe the output.
19 years ago
I know the output that it'll call baap's method but just want to know why this is so?
Any full proof answer?
19 years ago
private methods can be overridden
execute the following code
class BAAP
{
private void meth()
{
System.out.println("Baap");
}
public static void main(String[] args)
{
BAAP b = new BETA();
b.meth();
}
}
class BETA extends BAAP
{
//private void meth()
public void meth()
{
System.out.println("Beta");
}
}

isnt it an example of overriding?
19 years ago
you mean to say private methods cann't be overridden?
19 years ago
What output do you expect and WHY?
************************************

class BAAP
{
private void meth()
{
System.out.println("Baap");
}
public static void main(String[] args)
{
BAAP b = new BETA();
b.meth();
}
}
class BETA extends BAAP
{
private void meth()
{
System.out.println("Beta");
}
}
19 years ago