I not only use all the brains that I have, but all that I can borrow. [Laurence J. Peter]
SCJP 1.4, SCSA 8.0, CCNA<br />IBM Certified Specialist AIX<br />Microsoft MCSD
I not only use all the brains that I have, but all that I can borrow. [Laurence J. Peter]
SCJP 1.4, SCSA 8.0, CCNA<br />IBM Certified Specialist AIX<br />Microsoft MCSD
15.11.4 Runtime Evaluation of Method Invocation
At run time, method invocation requires five steps. First, a target reference may be computed. Second, the argument expressions are evaluated. Third,
the accessibility of the method to be invoked is checked. Fourth, the actual code for the method to be executed is located. Fifth, a new activation frame
is created, synchronization is performed if necessary, and control is transferred to the method code.
Compile time error
Runtime error
Prints "Parent's method2() Parent's method1()"
Prints "Parent's method2() Child's method1()"
Correct Answer:
"Prints "Parent's method2() Parent's method1()"" is correct !
15.11.1 Compile-Time Step 1: Determine Class or Interface to Search:
# If the form is MethodName, then there are three subcases:
* If it is a simple name, that is, just an Identifier, then the name of the method is the Identifier and the class or interface to search is the one whose declaration contains the method invocation.
15.11.2.1 Find Methods that are Applicable and Accessible
The class or interface determined by the process described in �15.11.1 is searched for all method declarations applicable to this method invocation; method definitions inherited from superclasses and superinterfaces are included in this search.
The following compile-time information is then associated with the method invocation for use at run time:
* The invocation mode, computed as follows:
o Otherwise, if the compile-time declaration has the private modifier, then the invocation mode is nonvirtual.
15.11.4.1 Compute Target Reference (If Necessary)
o If the MethodName is a simple name, that is, just an Identifier, then there are two subcases:
+ If the invocation mode is static, then there is no target reference.
+ Otherwise, the target reference is the value of this.
15.11.4.4 Locate Method to Invoke
The strategy for method lookup depends on the invocation mode.
If the invocation mode is nonvirtual, overriding is not allowed. Method m of class T is the one to be invoked.
SCJP2. Please Indent your code using UBB Code
SCJP2. Please Indent your code using UBB Code
Originally posted by Jose Botella:
private members should not be accessed by public methods![]()
SCJP2. Please Indent your code using UBB Code
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|