题目内容

class MNA {private void f() {}class A {private void g() {}public class B {void h() {g();f();}}}}public class MultiNestingAccess {public static void main(String[] args) {MNA mna = _____(1)____; //生成MNA类的实例MNA.A mnaa = ____(2)______; //生成A类的实例MNA.A.B mnaab = __(3)______; //生成B类的实例____(4)____; //调用方法h()}}

查看答案
更多问题

请写出以下程序在控制台的输出。class Super{static String greeting(){ return "Good night"; }String name(){ return "Tom"; }}class Sub extends Super{static String greeting(){ return "Hello"; }String name(){ return "Mary"; }}public class test{public static void main(String[] args){Super s = new Sub();System.out.println( s.greeting() +"," + s.name() );}}

请写出以下程序在控制台的输出。interface InTest{ void testPrintln(); void lambda(); }class Outer implements InTest{public void testPrintln(){ System.out.println("One"); }public void lambda(){ System.out.println("Outer"); testPrintln(); }}public class TestInner {static class Inner extends Outer{public void testPrintln(){ System.out.println("Two"); }public void lambda(){ System.out.println("Inner" ); testPrintln(); }}public static void main(String[]args){InTest tmp =new Outer();tmp.lambda();tmp=new Inner(); tmp.lambda();tmp =new Outer(){public void testPrintln(){ System.out.println("Three");}public void lambda(){System.out.println("Annoy" );super.testPrintln();}};tmp.lambda();}}

请写出下面程序的运行结果class A {public A() {System.out.print("1");}static { System.out.print("2"); }}class B extends A {public B() {System.out.print("3");}static { System.out.print("4"); }}public class test {public static void main(String[] args) {new B();}}

请写出下面程序的运行结果class A {public static String staticGet() {return "1"; }public String dynamicGet() {return "2"; }}class B extends A {public static String staticGet() {return "3"; }public String dynamicGet() {return "4"; }}public class test {public static void main(String[] args) {A a = new B();System.out.print( a.staticGet() );System.out.print( a.dynamicGet() );}}

答案查题题库