更多“Public pro... 默认 private 的区别”相关问题
  • 第1题:

    说明Friendly,private,protect,public四者间的区别?


    正确答案:
     

  • 第2题:

    请说出作用域publicprivateprotected,以及不写时的区别

     


    说明:如果在修饰的元素上面没有写任何访问修饰符,则表示friendly。                  

                     当前类              同一package          子孙类         其他包

    public            √                                           √                     √                     

    protected         √                      √               √              ×

    friendly          √                      √               ×              ×

    private           √                      ×               ×              ×

     

  • 第3题:

    简述作用域public,protected,private,以及不写时的区别。


    正确答案:public在其他的包中的类也可以引用,protected只限于同一个包内的类,private只有自己可以使用。不写的时候和protected一样。

  • 第4题:

    PKI是()。

    • A、Private Key Infrastructure
    • B、Public Key Institute
    • C、Public Key Infrastructure公钥基础设施
    • D、Private Key Institute

    正确答案:C

  • 第5题:

    public/protect/private/internal修饰符的区别


    正确答案: public:对任何类和成员都公开,无限制访问;
    protected:仅仅对该类以及该类的派生类公开;
    private:仅仅对该类公开;
    internal:只能值包含该类的程序集中访问该类(只是单独的项目,而不是整个解决方案);
    protectedinternal:只能在本类,派生类或者包含该类的程序集中访问

  • 第6题:

    Which the two demonstrate an “is a” relationship?()

    • A、 public interface Person {}  Public class Employee extends Person {}
    • B、 public interface Shape {}  public interface Rectangle extends Shape {}
    • C、 public interface Color {}  public class Shape { private Color color; }
    • D、 public class Species {}  public class Animal { private Species species; }
    • E、 interface Component {} Class Container implements Component {private Component [] children;

    正确答案:B,E

  • 第7题:

    Which three form part of correct array declarations?()  

    • A、 public int a []
    • B、 static int [] a
    • C、 public [] int a
    • D、 private int a [3]
    • E、 private int [3] a []
    • F、 public final int [] a

    正确答案:A,B,F

  • 第8题:

    PKI的全称是()。

    • A、Private Key Intrusion
    • B、Public Key Intrusion
    • C、Private Key Infrastructure
    • D、Public Key Infrastructure

    正确答案:D

  • 第9题:

    判断题
    包的访问控制分为public protected private 和默认,默认时为public。
    A

    B


    正确答案:
    解析: 暂无解析

  • 第10题:

    问答题
    public/protect/private/internal修饰符的区别

    正确答案: public:对任何类和成员都公开,无限制访问;
    protected:仅仅对该类以及该类的派生类公开;
    private:仅仅对该类公开;
    internal:只能值包含该类的程序集中访问该类(只是单独的项目,而不是整个解决方案);
    protectedinternal:只能在本类,派生类或者包含该类的程序集中访问
    解析: 暂无解析

  • 第11题:

    多选题
    Which the two demonstrate an “is a” relationship?()
    A

    public interface Person {}  Public class Employee extends Person {}

    B

    public interface Shape {}  public interface Rectangle extends Shape {}

    C

    public interface Color {}  public class Shape { private Color color; }

    D

    public class Species {}  public class Animal { private Species species; }

    E

    interface Component {} Class Container implements Component {private Component [] children;


    正确答案: A,C
    解析: 暂无解析

  • 第12题:

    多选题
    public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()
    A

    public class Circle implements Shape { private int radius; }

    B

    public abstract class Circle extends Shape { private int radius; }

    C

    public class Circle extends Shape { private int radius; public void draw(); }

    D

    public abstract class Circle implements Shape { private int radius; public void draw(); }

    E

    public class Circle extends Shape { private int radius;public void draw() {/* code here */} }

    F

    public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }


    正确答案: B,F
    解析: 暂无解析

  • 第13题:

    作用域public,private,protected,以及不写时的区别


    正确答案:

     

    区别如下:
    作用域 当前类 同一package 子孙类 其他package
    public √ √ √ √
    protected √ √ √ ×
    friendly √ √ × ×
    private √ × × ×
    不写时默认为friendly

  • 第14题:

    Java中,未带访问权限修饰符的成员变量默认为 ( ) 。

    A.Public]
    B.Private]
    C.Protected]
    D.Friendly

    答案:D
    解析:
    本题考查Java中成员变量的类型。在Java中,类中所定义的数据或者变量叫做实例变量或成员变量,它提供了一组访问修饰来限制对成员变量和成员函数的访问权限,包括:Public 公有类型的成员可以被所有类访问。Private 私有类型的成员只能被这个类本身所访问。Protected 保护类型的成员只能被这个类本身,它的子类以及同一个包中所有的其他类访问。Friendly 友元类型的成员可以被这个类本身和同一个包中的所有类访问。如果成员变量不加任何修饰符,则默认为Friendly类型。

  • 第15题:

    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

  • 第16题:

    包的访问控制分为public protected private 和默认,默认时为public。


    正确答案:错误

  • 第17题:

    public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()

    • A、 public void aMethod() {}
    • B、 private void aMethod() {}
    • C、 public void aMethod(String s) {}
    • D、 private Y aMethod() { return null; }
    • E、 public X aMethod() { return new Y(); }

    正确答案:C,E

  • 第18题:

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

    • A、 public interface Person { }  public class Employee extends Person { }
    • B、 public interface Shape { }  public class Employee extends Shape { }
    • C、 public interface Color { }  public class Employee extends Color { }
    • D、 public class Species { }  public class Animal (private Species species;)
    • E、 interface Component { }  Class Container implements Component ( Private Component[ ] children;  )

    正确答案:D,E

  • 第19题:

    public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()

    • A、 public class Circle implements Shape { private int radius; }
    • B、 public abstract class Circle extends Shape { private int radius; }
    • C、 public class Circle extends Shape { private int radius; public void draw(); }
    • D、 public abstract class Circle implements Shape { private int radius; public void draw(); }
    • E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
    • F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

    正确答案:B,E

  • 第20题:

    PKI是()。

    • A、Private Key lnfrastructure
    • B、Public Key lnstitute
    • C、Public Key lnfrastructure
    • D、Private Key lnstitute

    正确答案:C

  • 第21题:

    问答题
    简述作用域public,protected,private,以及不写时的区别。

    正确答案: public在其他的包中的类也可以引用,protected只限于同一个包内的类,private只有自己可以使用。不写的时候和protected一样。
    解析: 暂无解析

  • 第22题:

    单选题
    From this text we learn that it is ______.
    A

    harder to make a choice between public and private schools

    B

    harder to go to private schools this year than before

    C

    more difficult to go to public schools than to private schools

    D

    as difficult to go to private schools this year as before


    正确答案: D
    解析:
    细节题。由全文第一句可知,进入国内一流私立学校的竞争一向很激烈,但今年伊莉莎白发现这种状况又升级了。即今年进入私立学校比往年更难,故B项为正确答案。该句中的tough对应选项中的hard,而reach a new level则对应选项中所用的比较级。

  • 第23题:

    多选题
    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; }


    正确答案: E,B
    解析: 暂无解析