4、Outer类中定义了一个成员内部类Inner,需要在main()方法中创建Inner类实例对象,以下四种方式哪一种是正确的?()A.Inner in = new Inner()B.Inner in = new Outer.Inner();C.Outer.Inner in = new Outer.Inner();D.Outer.Inner in = new Outer().new Inner();

4、Outer类中定义了一个成员内部类Inner,需要在main()方法中创建Inner类实例对象,以下四种方式哪一种是正确的?()

A.Inner in = new Inner()

B.Inner in = new Outer.Inner();

C.Outer.Inner in = new Outer.Inner();

D.Outer.Inner in = new Outer().new Inner();


参考答案和解析
正确

相关考题:

下列关于内部类的说法不正确的是A.内部类的类名只能在定义它的类或程序段中或在表达式内部匿名使用B.内部类可以使用它所在类的静态成员变量和实例成员变量C.内部类不可以用abstract修饰符定义为抽象类D.内部类可作为其他类的成员,而且前访问它所在类的成员

请在每条横线处填写一个语句,使程序的功能完整,且输出结果为91 1。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序文件代码清单如下:public class Outer{public static void main (String args[]{Outer i = new Outer();i,taskInner();}public class Inner{private int size;public void doSomething(int size){_____________//访问局部变量this. size++; //访问内部类的成员变量_____________//访问外部类的成员变量System.out.println(size+" "+this.size+" "+Outer.this.size);}}public void taskInner(){___________k.doSomething(8);}private static int size;}

以下关于类和对象的叙述中,正确的是__(44) 。A.对象是类的实例B.每个类都必须创建一个实例C.每个类只能创建一个实例D.类的实例化是指对类进行初始化

下列关于内部类的说法中不正确的是( )。A.内部类的类名只能在定义它的类或程序段中或在表达式内部匿名使用B.内部类可以使用它所在类的静态成员变量和实例成员变量C.内部类不可以用abstract 修饰符定义为抽象类D.内部类可作为其他类的成员,而且可访问它所在类的成员

内部类是在一个类内嵌套定义的类。其特点描述错误的是 ( )A.只能在定义它的类或程序段中或表达式内匿名使用,外部使用时必须给出类的全名B.可以使用它所在类的静态成员变量或实例成员变量,但不可以使用所在类中的局部变量C.可作为其他类的成员,而且可访问它所在类的成员D.除static内部类外,不能在类内声明static成员

以下关于内部类的说明中不正确的是( )。A.内部类可以声明为public、private或protectedB.内部类不可以定义为abstractC.内部类不能与包含它的类名相同D.内部类可以使用包含它的类的成员变量,包括静态和实例成员变量,也可以使用内部类所在方法的局部变量

以下程序的调试结果为?public class Outer{public String name = "Outer";public static void main(String argv[]){Inner i = new Inner();i.showName();}private class Inner{String name =new String("Inner");void showName(){System.out.println(name);}}}A.输出结果 OuterB.输出结果 InnerC.编译错误,因Inner类定义为私有访问D.在创建Inner类实例的行出现编译错误

关于静态成员,下列说法正确的是()A、 同一个类中的静态成员,类实例化后,在不同的对象中形成不同的静态成员B、 在类实例化后,同类型的对象都共享类的静态成员,静态成员只有一个版本C、 在类定义时静态成员属于类,在类实例化后静态成员属于对象D、 在类实例化后静态成员已被实例化,因此不同的对象有不同的静态成员

1. public class Outer{  2. public void someOuterMethod() {  3. // Line 3  4. }  5. public class Inner{}  6. public static void main( String[]argv ) {  7. Outer o = new Outer();  8. // Line 8  9. }  10. }  Which instantiates an instance of Inner?()  A、 new Inner(); // At line 3B、 new Inner(); // At line 8C、 new o.Inner(); // At line 8D、 new Outer.Inner(); // At line 8

What is true regarding subqueries?()A、The inner query always sorts the results of the outer queryB、The outer query always sorts the results of the inner queryC、The outer query must return a value to the outer queryD、The inner query returns a value to the outer queryE、The inner query must always return a value or the outer query will give an error

下列关于内部类的说法不正确的是()A、内部类的类名只能在定义它的类或程序段中或在表达式内部匿名使用B、内部类可以使用它所在类的静态成员变量和实例成员变量C、内部类不可以用abstract修饰符定义为抽象类D、内部类可作为其他类的成员,而且可访问它所在类的成员

下列连接中能自动删除重复的列是()。A、INNER JOINB、LEFT OUTER JOINC、RIGHT OUTER JOIND、FULL OUTER JOIN

关于main()方法说法正确的是()A、一个类中可以没有main()B、所有对象都必须放在main()方法中C、main()必须放在公共类中D、main()方法头的定义可以根据情况任意修改

关于线程的创建过程,下面四种说法正确的有哪些?()A、定义Thread类的子类,重写Thread类的run()方法,创建该子类的实例对象,调用对象的start()方法B、定义Thread类的子类,重写Thread类的run()方法,创建该子类的实例对象,调用对象的run()方法C、定义一个实现Runnable 接口的类并实现run()方法,创建该类实例对象,将其作为参数传递给Thread类的构造方法来创建Thread对象,调用Thread对象的start()方法D、定义一个实现Runnable 接口的类并实现run()方法,创建该类对象,然后调用run()方法

假定要在一个类XXK5中访问另一个类XXK4中的实例成员abc,则首先要在XXK5中创建()类的一个实例对象,然后通过这个对象进行访问。

package foo; public class Outer (  public static class Inner (  )  )   Which statement is true? () A、 An instance of the Inner class can be constructed with “new Outer.Inner ()”B、 An instance of the inner class cannot be constructed outside of package foo.C、 An instance of the inner class can only be constructed from within the outer class.D、 From within the package bar, an instance of the inner class can be constructed with “new inner()”

class Birds {  public static void main(String [] args) {  try {  throw new Exception();  } catch (Exception e) { try {  throw new Exception();  } catch (Exception e2) { System.out.print("inner "); }  System.out.print("middle "); }  System.out.print("outer ");  }  }  结果为:()  A、innerB、inner outerC、middle outerD、inner middle outer

What is true regarding subqueries?()A、The inner query always sorts the results of the outer query.B、The outer query always sorts the results of the inner query.C、The outer query must return a value to the inner query.D、The inner query returns a value to the outer query.E、The inner query must always return a value or the outer query will give an error.

填空题假定要在一个类XXK5中访问另一个类XXK4中的实例成员abc,则首先要在XXK5中创建()类的一个实例对象,然后通过这个对象进行访问。

单选题关于静态成员,下列说法正确的是()A 同一个类中的静态成员,类实例化后,在不同的对象中形成不同的静态成员B 在类实例化后,同类型的对象都共享类的静态成员,静态成员只有一个版本C 在类定义时静态成员属于类,在类实例化后静态成员属于对象D 在类实例化后静态成员已被实例化,因此不同的对象有不同的静态成员

单选题While a ship with twin screw is making a turn, in order to prevent overload, the duty engineer should ()Areduce the fuel feeding of main engine of inner propellerBreduce the fuel feeding of main engine of outer propellerCfirstly reduce the fuel of main engine of inner propeller, then reduce the fuel feeding of engine of outer propellerDreduce fuel feeding of two engines at the same time

多选题关于线程的创建过程,下面四种说法正确的有哪些?()A定义Thread类的子类,重写Thread类的run()方法,创建该子类的实例对象,调用对象的start()方法B定义Thread类的子类,重写Thread类的run()方法,创建该子类的实例对象,调用对象的run()方法C定义一个实现Runnable 接口的类并实现run()方法,创建该类实例对象,将其作为参数传递给Thread类的构造方法来创建Thread对象,调用Thread对象的start()方法D定义一个实现Runnable 接口的类并实现run()方法,创建该类对象,然后调用run()方法

单选题What is true regarding subqueries?()AThe inner query always sorts the results of the outer queryBThe outer query always sorts the results of the inner queryCThe outer query must return a value to the outer queryDThe inner query returns a value to the outer queryEThe inner query must always return a value or the outer query will give an error

单选题1. public class Outer{  2. public void someOuterMethod() {  3. // Line 3  4. }  5. public class Inner{}  6. public static void main( String[]argv ) {  7. Outer o = new Outer();  8. // Line 8  9. }  10. }  Which instantiates an instance of Inner?()A new Inner(); // At line 3B new Inner(); // At line 8C new o.Inner(); // At line 8D new Outer.Inner(); // At line 8

单选题package foo; public class Outer (  public static class Inner (  )  )   Which statement is true? ()A An instance of the Inner class can be constructed with “new Outer.Inner ()”B An instance of the inner class cannot be constructed outside of package foo.C An instance of the inner class can only be constructed from within the outer class.D From within the package bar, an instance of the inner class can be constructed with “new inner()”

单选题package foo;  public class Outer {  public static class Inner {  }  }   Which statement is true?()A Compilation fails.B An instance of the Inner class can be constructed with “new Outer.Inner()”.C An instance of the Inner class cannot be constructed outside of package foo.D An instance of the Inner class can be constructed only from within the Outer class.E From within the package foo, and instance of the Inner class can be constructed with “new Inner()”.

多选题Which statements concerning the correlation between the inner and outer instances of non-static inner classes are true?()AMember variables of the outer instance are always accessible to inner instances, regardless of their accessibility modifiers.BMember variables of the outer instance can never be referred to using only the variable name within  the inner instance.CMore than one inner instance can be associated with the same outer instance.DAll variables from the outer instance that should be accessible in the inner instance must be declared  final.EA class that is declared final cannot have any inner classes.

单选题What is true regarding subqueries?()AThe inner query always sorts the results of the outer query.BThe outer query always sorts the results of the inner query.CThe outer query must return a value to the inner query.DThe inner query returns a value to the outer query.EThe inner query must always return a value or the outer query will give an error.