1. Yes it can access it as normally as class 2 would access it.
2. super() would call the class2's constructor, but it'd also trigger the constructor-chain which will call class 1 and so on. You need to be careful with that.
3. Not exactly, but you can use something called as a "Package" to work around this issue.
Here's an example regarding the first two questions:
Code:
class Foo
{
Foo()
{
System.out.println("Foo-Constructor Called.");
}
// Below one won't show up cause its not explicitly called.
// But the Foo() is called nevertheless, after Bar(someInt)
Foo(int someInt)
{
System.out.println("Foo-Constructor Called with " + someInt);
}
void doFoo()
{
System.out.println("Foo did something.");
}
}
class Bar extends Foo
{
Bar()
{
System.out.println("Bar-Constructor Called.");
}
Bar(int someInt)
{
/* super(someInt); */
System.out.println("Bar-Constructor Called with " + someInt);
}
void doBar()
{
System.out.println("Bar did something.");
}
}
class Spam extends Bar
{
Spam()
{
super(16);
System.out.println("Spam-Constructor Called.");
}
void doSpam()
{
System.out.println("Spam did something.");
}
}
class Eggs
{
public static void main(String args[])
{
Spam objSpam = new Spam();
objSpam.doFoo();
objSpam.doBar();
objSpam.doSpam();
}
}
// Eggs.java