1. Is this code compile ?
2. ins.a() is correct?
3.ins.b() is correct ?
4. what is ins.x value ?
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Meghna Bhardwaj wrote:I am completely confused...what is this ???
as it stands your code will NOT compile at all!!
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
1. can we override a static method ?
2. If a super class object ref the subclass what will be the runtime reference of the object?
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Anitha Srinivasan wrote:
Anitha Srinivasan wrote:
While the reference is pointing to a B, as far as the JVM is concerned ins is an A reference variable.
Anitha Srinivasan wrote:
So ins.b() will throw a compilation error? since ins is a A reference variable , A does not have method b.
Anitha Srinivasan wrote:
one more doubt
final A ins =new A();
ins.x=5;
Here i am creating a final class reference ins. And i am trying to assign ins.x=5 ; can i assign a value for final class variable ?
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
Anitha Srinivasan wrote:Thanks.
Can i reassign a class variable to final class ref?
for example,
class A{
int x=0;}
class B extends class A{
int x =1;};
public static void main(args []){
final A ins=new A();
ins.x=5;
}
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
Don't get me started about those stupid light bulbs. |