Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!

Salil S Fadnavis

Greenhorn
+ Follow
since Jan 03, 2006
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 Salil S Fadnavis

Look at the code below


aMethod is overridden
if reducing the visibility was allowed how would dynamic method resolution work.


This could would compile but during runtime give a error (if reducing the visibility was allowed on methods). So i guess they have not allowed such stuff.

correct me if i am wrong.


this code will give a output of i is 11 and j is 10. So you could use them as constants??? . Dont see any real use of them.
Hi,

When an instance method is invoked on an object using an reference, it is the class of the object denoted by the reference and not the type that determines which method to invoke.

AND

When a field/memeber of an object is accessed using a reference it is the type of the reference and not the class of the current object that determines which field is called.

(above explanation is from KM)

so....
oBase.i calls field in class Base and
oBase.methodA() calls method of class Sub