Which of the following code fragments shows the correct way to declare and initialize a reference to a NestedClass object from outside BaseClass? : Questions « Object Oriented « SCJP
6.15.25.Which of the following code fragments shows the correct way to declare and initialize a reference to a NestedClass object from outside BaseClass?
class BaseClass {
BaseClass() {
}
public class NestedClass {
NestedClass() {
}
}
}
A. BaseClass.NestedClass myNC = new BaseClass.NestedClass();
B. NestedClass myNC = new BaseClass().new NestedClass();
C. NestedClass myNC = new BaseClass.NestedClass();
D. BaseClass.NestedClass nbc = new BaseClass().new NestedClass();