Inheritance in Java
- by stevebot
If I have an abstract class in java named Foo and it has an implementor named Bar then I want to know the following.
lets say Foo looks something like
public abstract class Foo {
Service serviceFoo
...
}
And Bar is
public class Bar extends Foo {
...
}
Also, lets assume I have an instance with Foo, named foo, currently that has serviceFoo instantiated
If I then declare:
Foo foo = new Bar();
will this create a a new instance of Bar that has serviceFoo instantiated or not? E.g. will that field be inherited and instantiated or just inherited?