现有:   public interface A {}   以下哪项声明是合法的?() 

题目
单选题
现有:   public interface A {}   以下哪项声明是合法的?()
A

a = new A();

B

 A[] a = new A[];

C

 A[] a = new A[10];

D

 以上皆错

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

在使用interface声明一个接口时,可以使用______修饰符修饰该接口。

A.private protected

B.protected

C.private

D.public


正确答案:D

第2题:

interface 声明一个接口时,成员方法默认的修饰符是()

A. private

B. 友好的

C. abstract

D. public abstract


正确答案:D

第3题:

现有:publicinterfaceA{}以下哪项声明是合法的?()

A.a=newA();

B.A[]a=newA[];

C.A[]a=newA[10];

D.以上皆错


参考答案:C

第4题:

Which three demonstrate an “is a” relationship?() 

  • A、 public class X {  }     public class Y extends X { }
  • B、 public interface Shape { }     public interface Rectangle extends Shape{ }
  • C、 public interface Color { }     public class Shape { private Color color; }
  • D、 public interface Species { }     public class Animal { private Species species; }
  • E、 public class Person { }    public class Employee {      public Employee(Person person) { }
  • F、 interface Component { }     class Container implements Component {   private Component[] children; }

正确答案:A,B,F

第5题:

现有:   public interface A {}   以下哪项声明是合法的?() 

  • A、a = new A();
  • B、 A[] a = new A[];
  • C、 A[] a = new A[10];
  • D、 以上皆错

正确答案:C

第6题:

下列哪个类声明是正确的? ( )

A.abstract class G2 extends superClass1,superClass2{...}

B.abstract public class classmates{...}

C.public final class NewClass extends superClass implemnets Interface1{...}

D.public abstract class String{...}


正确答案:C
解析:本题考查对类声明的掌握程度。选项A错误,Java不支持多重继承,故extends关键字后只能接一个父类;选项B错误,在类声明中public关键字必须位于abstract关键字前;选项C正确,声明了一个公有的不能继承的类,这个类的父类是superClass,并使用了Interfacel提供的接口,类不能声明为protected和pfivate属性且不以“;”结尾:选项D错误,String是Java中字符串的关键字,不能用于类名。

第7题:

public interface A {  String DEFAULT_GREETING = “Hello World”;  public void method1();  }  A programmer wants to create an interface called B that has A as its parent. Which interface declaration is correct?() 

  • A、 public interface B extends A {}
  • B、 public interface B implements A {}
  • C、 public interface B instanceOf A {}
  • D、 public interface B inheritsFrom A {}

正确答案:A

第8题:

在使用interface声明一个接口时,只可以使用( )修饰符修饰该接口。

A.private

B.protected

C.pnvate protected

D.public


正确答案:D

第9题:

现有:  1.  interface Animal  f      2.    void eat();      3.    }      4.  5.  // insert code here      6.  7. public class HouseCat implements Feline  {      8.    public void eat()    {  }     9.  }  和以下三个接口声明:  interface Feline extends Animal  (  )  interface Feline extends Animal  {void eat();    }  interface Feline extends Animal  {void eat()    {  }  }   分别插入到第5行,有多少行可以编译?   

  • A、  0
  • B、  1
  • C、  2
  • D、  3

正确答案:C

第10题:

在使用interface声明一个接口时,只可以使用()修饰符修饰该接口。 

  • A、private
  • B、protected
  • C、private  protected
  • D、public

正确答案:D

更多相关问题