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?()
第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
第2题:
下列哪个成员方法声明是正确的? ( )
A.public abstract final int f(){...}
B.public static boolean f(){...}
C.static protected void g(a,{...}
D.protected private number;
第3题:
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[] );
第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 }
第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?()
第6题:
Which the two demonstrate an “is a” relationship?()
第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?()
第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?()
第9题:
public void setEnabled( boolean enabled) public boolean getEnabled()
public void setEnabled( boolean enabled) public void isEnabled()
public void setEnabled( boolean enabled) public boolean isEnabled()
public boolean setEnabled( boolean enabled) public boolean getEnabled()
第10题:
Public void mouseMoved(MouseEvent)
Public boolean mouseMoved(MouseEvent)
Public void mouseMoved(MouseMotionEvent)
Public boolean MouseMoved(MouseMotionEvent)
Public boolean mouseMoved(MouseMotionEvent)
第11题:
A
B
C
D
第12题:
The program prints “0”
The program prints “4”
The program prints “8”
The program prints “12”
The code does not complete.
第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.编译错误
第14题:
下列哪个成员方法声明是正确的? ( )
A.public abstract final int f(){…}
B.public static boolean f(){…}
C.static protected void g(a,b){…}
D.protected private number;
第15题:
以下哪个方法可以用来获得进度条的当前进度值?()
第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) {} }
第17题:
Which is a method of the MouseMotionListener interface?()
第18题:
Which two demonstrate an “is a” relationship?()
第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?()
第20题:
The code will fail to compile.
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.
Class c has three constructors.
Objects of class b cannot be constructed.
At most one of the constructors of each class is called as a result of constructing an object of class c.
第21题:
1
null
0
编译错误
第22题:
True
Not true
An exception is thrown at runtime.
Compilation fails because of an error at line 12.
Compilation fails because of an error at line 19.
第23题:
public int hashCode()
public boolean equals(Key k)
public int compareTo(Object o)
public boolean equals(Object o)
public boolean compareTo(Key k)