A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()A、 public void setEnabled( boolean enabled) public boolean getEnabled()B、 public

题目

A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()

  • A、 public void setEnabled( boolean enabled) public boolean getEnabled()
  • B、 public void setEnabled( boolean enabled) public void isEnabled()
  • C、 public void setEnabled( boolean enabled) public boolean isEnabled()
  • D、 public boolean setEnabled( boolean enabled) public boolean getEnabled()

相似考题

1.【Java代码】import Java.util.ArrayList;import java.util.List;(1) class AbstractFile{protected String name;public void printName(){System.out.println(name);}public abstract boolean addChild(AbstractFile file);public abstract boolean removeChild(AbstractF ile file);public abstract List<AbstractFile> getChildren();}class File extends AbstractFile{public File(String name){this.name=name;}public boolean addChild(AbstractFile file){return false;}public boolean removeChild(AbstractFile file){return false;}public List<AbstractFile> getChildren(){return (2) ;}}class Folder extends AbstractFile{private List <AbslractFile> childList;public Folder(String name){this.name=name;this.childList=new ArrayList<AbstractFile>();}public boolean addChild(AbstractFile file) { return childList.add(file);}public boolean removeChild(AbstractFile file){return childList.remove(file);}public (3) <AbstractFile> getChildren(){return (4) ;}}public class Client{public static void main(String[] args){//构造一个树形的文件/目录结构AbstractFile rootFolder= new Folder("c:\\ ");AbstractFile compositeFolder=new Folder("composite");AbstractFile windowsFolder=new Folder("windows");AbstractFile file=new File("TestComposite.java");rootFolder.addChild(compositeFolder) ;rootFolder.addChild(windowsFolder);compositeFolder.addChild(file) ;//打印目录文件树printTree(rootFolder);}private static void printTree(AbslractFile ifile){ifile.printName();List <AbslractFile> children=ifile.getChildreno:if(children==null) return;for (AbstractFile file:children) {(5) ;}}}该程序运行后输出结果为:c:\compositeTestComposite.javaWindows

更多“A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()A、 public void setEnabled( boolean enabled) public boolean getEnabled()B、 public ”相关问题
  • 第1题:

    阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。

    【说明】

    现欲构造一文件/目录树,采用组合(Composite)设计模式来设计,得到的类图如6—8所示:

    【Java代码】

    import JavA.util.ArrayList;

    import JavA.util.List;(1)class AbstractFile{

    protected String name;

    public void printName(){System.out.println(name);}

    public abstract boolean addChild(AbstractFile file);

    public abstract boolean removeChild(AbstractFile file);

    public abstract ListgetChildren {};

    }

    class File extends AbstractFile{

    public File(String name)(this.name=name;}

    public boolean addChild(AbstractFile file){return false;}

    public boolean removeChild(AbstractFile file){return false;}

    public ListgetChildren(){return (2) ;)

    }

    clasS Folder extends AbstractFile{

    private ListchildList;

    public Folder(String name){

    thiS.name=name;

    this.childList=new ArrayList{};

    }

    public boolean addChild(AbstractFile file){return childList.add(file);}

    public boolean removeChild(AbstractFile file){return childList.remove(file);

    public (3)getChildren(){return (4) ;)

    }

    public class Client{

    public static void main(String[]args){

    //构造一个树形的文件/目录结构

    AbstractFile rootFolder=new Folder(“C:\”’);

    AbstractFile compositeFolder=new Folder(”composite”);

    AbstractFile windowsFolder=new Folder(”windows”);

    AbstractFile file=new File(”TestComposite.java”);

    rootFOlder.addChild (compositeFolder);

    rootFolder.addChiid(windowsFolder);

    compositeFolder.addChild(file);

    //打印目录文件树

    printTree(rootFolder);

    }

    private static void printTree(AbstractFile ifile){

    ifile.PrIntName();

    Listchildren:ifile.getChildren ();

    if(chiidren==null)return;

    for(AbstractFile file:children){(5) ;

    }

    }

    }

    该程序运行后输出结果为:

    C:\

    composite

    TestComposite.java

    Windows


    正确答案:(1)Abstract(2)null(3)List(4)childList(5)printTree(file)
    (1)Abstract(2)null(3)List(4)childList(5)printTree(file) 解析:Composite模式定义:将对象以树型结构组织起来,以达成“部分-整体”的层次结构,使得客户端对单个对象和组合对象的使用具有一致性。Composite比较容易理解,想到Composite就应该想到树型结构图。组合体内这些对象都有共同接口,当组合体一个对象的方法被调用执行时,Composite将遍历(Iterator)整个树形结构,寻找同样包含这个方法的对象并实现调用执行。AbstractFile为一个抽象文件类,其作用主要是实现对文件或者文件夹的抽象。文件类File继承自AbstractFile。File(stringname)为File类的一个属性,用于获取文件名称。Add-child方法用来给一个目录增加子目录或文件。Removechild方法用于删除一个目录的子目录或文件。Getchildren方法用于获取一个目录或文件,所以返回值类型应该是一个列表形式的AbstractFile,但文件本身不包括子目录,故返回NUIJIJ。Fold类表示一个文件夹,属性Folder用于获取文件夹名称,Getchildren方法返回值应为List型的AbstractFile对象指针。

  • 第2题:

    下列哪个成员方法声明是正确的? ( )

    A.public abstract final int f(){...}

    B.public static boolean f(){...}

    C.static protected void g(a,{...}

    D.protected private number;


    正确答案:B
    解析:本题考查对成员方法声明的掌握程度。选项A错误,成员变量不能同时声明成abstract和final;选项B正确,声明了一个公有静态返回值类型是布尔类型的方法f();选项C错误,protected应在static之前;选项D错误,既不是方法声明,也不是正确的成员变量声明。

  • 第3题:

    以下哪个是Java应用程序main方法的有效定义?

    A. public static void main();

    B. public static void main( String args );

    C. public static void main( String args[] );

    D. public static void main( Graphics g );

    E. public static boolean main( String a[] );


    正确答案:C

  • 第4题:

    Which lines of code are valid declarations of a native method when occurring within the declaration of the following class?()    public class Qf575 {   // insert declaration of a native method here   }  

    • A、native public void setTemperature(int kelvin);
    • B、private native void setTemperature(int kelvin);
    • C、protected int native getTemperature();
    • D、public abstract native void setTemperature(int kelvin);
    • E、native int setTemperature(int kelvin) {}

    正确答案:A,B

  • 第5题:

    11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?() 

    • A、 True
    • B、 Not true
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error at line 12.
    • E、 Compilation fails because of an error at line 19.

    正确答案:A

  • 第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题:

    public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()  

    • A、 The program prints “0”
    • B、 The program prints “4”
    • C、 The program prints “8”
    • D、 The program prints “12”
    • E、 The code does not complete.

    正确答案:B

  • 第8题:

    public class Key {  private long id1;  private long 1d2;  // class Key methods  }  A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()

    • A、 public int hashCode()
    • B、 public boolean equals(Key k)
    • C、 public int compareTo(Object o)
    • D、 public boolean equals(Object o)
    • E、 public boolean compareTo(Key k)

    正确答案:A,D

  • 第9题:

    多选题
    A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()
    A

    public void setEnabled( boolean enabled) public boolean getEnabled()

    B

    public void setEnabled( boolean enabled) public void isEnabled()

    C

    public void setEnabled( boolean enabled) public boolean isEnabled()

    D

    public boolean setEnabled( boolean enabled) public boolean getEnabled()


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

  • 第10题:

    单选题
    Which is a method of the MouseMotionListener interface?()
    A

     Public void mouseMoved(MouseEvent)

    B

     Public boolean mouseMoved(MouseEvent)

    C

     Public void mouseMoved(MouseMotionEvent)

    D

     Public boolean MouseMoved(MouseMotionEvent)

    E

     Public boolean mouseMoved(MouseMotionEvent)


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

  • 第11题:

    多选题
    A JavaBeans component has the following field:   11. private boolean enabled;   Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()
    A

    A

    B

    B

    C

    C

    D

    D


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

  • 第12题:

    单选题
    public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()
    A

     The program prints “0”

    B

     The program prints “4”

    C

     The program prints “8”

    D

     The program prints “12”

    E

     The code does not complete.


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

  • 第13题:

    下列代码的编译或执行结果是( )。 public class Myval{ public static void main(string args[]){ MyVal m=new MyVal; aMethod; } public void aMethod{ boolean b[]=new Boolean[5]; System.OUt.println(b[0]); } }

    A.1

    B.null

    C.0

    D.编译错误


    正确答案:A
    A。【解析】boolean类型的变量值只有ture或false,b[0]的默认初始值为false。

  • 第14题:

    下列哪个成员方法声明是正确的? ( )

    A.public abstract final int f(){…}

    B.public static boolean f(){…}

    C.static protected void g(a,b){…}

    D.protected private number;


    正确答案:B
    解析:本题考查对成员方法声明的掌握程度。选项A错误,成员变量不能同时声明成abstract 和 final;选项B正确,声明了一个公有静态返回值类型是布尔类型的方法 f();选项C错误,protected应在static之前;选项D错误,既不是方法声明,也不是正确的成员变量声明。

  • 第15题:

    以下哪个方法可以用来获得进度条的当前进度值?()

    • A、public synchronized int getProgress()
    • B、public synchronized void setIndeterminate (boolean indeterminate)
    • C、public synchronized void setProgress(int progress)
    • D、Public final synchronized void incrementProgressBy(int diff)

    正确答案:A

  • 第16题:

    Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }  

    • A、The code will fail to compile.
    • B、The constructor in a that takes an int as an argument will never be called as a result of constructing an     object of class b or c.
    • C、Class c has three constructors.
    • D、Objects of class b cannot be constructed.
    • E、At most one of the constructors of each class is called as a result of constructing an object of class c.

    正确答案:B,C

  • 第17题:

    Which is a method of the MouseMotionListener interface?()

    • A、 Public void mouseMoved(MouseEvent)
    • B、 Public boolean mouseMoved(MouseEvent)
    • C、 Public void mouseMoved(MouseMotionEvent)
    • D、 Public boolean MouseMoved(MouseMotionEvent)
    • E、 Public boolean mouseMoved(MouseMotionEvent)

    正确答案:A

  • 第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 void testIfA(){ if(testIfB("True")){ System.out.println("True"); }else{ System.out.println("Nottrue"); } } public Boolean testIfB(Stringstr){ return Boolean.valueOf(str); } What is the result when method testIfA is invoked?()

    • A、True
    • B、Nottrue
    • C、Anexceptionisthrownatruntime.
    • D、Compilationfailsbecauseofanerroratline12.
    • E、Compilationfailsbecauseofanerroratline19.

    正确答案:A

  • 第20题:

    多选题
    Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }
    A

    The code will fail to compile.

    B

    The constructor in a that takes an int as an argument will never be called as a result of constructing an     object of class b or c.

    C

    Class c has three constructors.

    D

    Objects of class b cannot be constructed.

    E

    At most one of the constructors of each class is called as a result of constructing an object of class c.


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

  • 第21题:

    单选题
    下列代码的编译或执行结果是(  )。 public class MyVal{ public static void main(String args[]){ MyVal m = new MyVal(); m.aMethod(); } public void aMethod(){ boolean b[] = new Boolean[5]; System.out.println(b[0]); } }
    A

    1

    B

    null

    C

    0

    D

    编译错误


    正确答案: D
    解析:
    boolean b[]=new Boolean[5];等号左右布尔类型大小写要一致,故会出现编译错误,选项D正确。

  • 第22题:

    单选题
    11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?()
    A

     True

    B

     Not true

    C

     An exception is thrown at runtime.

    D

     Compilation fails because of an error at line 12.

    E

     Compilation fails because of an error at line 19.


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

  • 第23题:

    多选题
    public class Key {  private long id1;  private long 1d2;  // class Key methods  }  A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()
    A

    public int hashCode()

    B

    public boolean equals(Key k)

    C

    public int compareTo(Object o)

    D

    public boolean equals(Object o)

    E

    public boolean compareTo(Key k)


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