单选题文件输出流的构造方法是 public FileOutputStream(String name,Boolean append)throws FileNotFoundException,当参数append的值为true时,表示()A创建一个新文件B在原文件的尾部添加数据C覆盖原文件的内容D在原文件的指定位置添加数据ensp;RandomAccess
单选题
文件输出流的构造方法是 public FileOutputStream(String name,Boolean append)throws FileNotFoundException,当参数append的值为true时,表示()
A
创建一个新文件
B
在原文件的尾部添加数据
C
覆盖原文件的内容
D
在原文件的指定位置添加数据 RandomAccess
参考解析
解析:
暂无解析
相关考题:
【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 ListAbstractFile 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 ListAbstractFile getChildren(){return (2) ;}}class Folder extends AbstractFile{private List AbslractFile childList;public Folder(String name){this.name=name;this.childList=new ArrayListAbstractFile();}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
本题中定义了一个带有参数的构造方法javal,并定义了一个该类的对象temp。构造方法javal有两个参数:字符串name和整型age。定义对象temp时将字符串“Tom"和整数17传递给构造方法,构造方法将这两个参数打印输出。 public class javal{ String name; int age; public static void main(String[]args){ String name="Tom"; int age=17; javal temp = ; } public javal(String name, ){ ; this.age= age; System.out.println(name+"is"+age+" years old."); } }
Java代码查错1.abstract class Name {private String name;public abstract boolean isStupidName(String name) {}}大侠们,这有何错误?
阅读下列说明和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:\compositeTestComposite.javaWindows
阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。[说明] 编写一个学生类Student,要求:(1) 学生类Student 属性有:id: long 型,代表学号name: String类对象,代表姓名age: int 型,代表年龄sex: boolen 型,代表性别(其中:true 表示男,false 表示女)phone: String 类对象,代表联系电话(2) 学生类Student 的方法有:Student (long i,String n,int a,boolean s,String p):有参构造函数,形参表中的参数分别初始化学号、姓名、年龄、性别和联系电话。int getAge ():获取年龄作为方法的返回值。boolean getSex ():获取性别作为方法的返回值。String getPhone ():获取联系电话作为方法的返回值。public String to String ():以姓名:性别:学号:联系电话的形式作为方法的返import java. applet. Applet;import java. awt.* ;public class Student extends Applet {long id;String name, phone;int age;boolean sex;Student(long i, String n, int a, boolean s, String p){id=i;name = n;age = a;sex= s;phone = p;{public void paint( Graphics g){Student x= new Student (5000," xiaoliu" , 89, true, " 8989898" );(1);(2)g. drawstring( x. getPhone( ), 140,140);}int getAge( ){ return age; }boolean getsex ( ){ return sex; }String getPhone( ){ return phone; }String ToString( ){(3)}}
Person p = new Person(“张三”,23);这条语句会调用下列哪个构造方法给属性进行初始化() A.public Person(){}B.public Person(String name,int age) { this.name = name; this.age = age; }C.public Person(int age,String name) { this.age = age; this.name = name; }D.public Person(String name) { this.name = name; }
执行以下代码后,下面哪些描述是正确的() public class Student{ private String name = “Jema”; public void setName(String name){ this.name = name; } public String getName(){ return this.name; } public static void main(String[] args){ Student s; System.out.println(s.getName()); } }A、输出nullB、第10行编译报错C、第11行编译报错D、输出Jema
public class Person { private String name, comment; private int age; public Person(String n, int a, String c) { name = n; age = a; comment = c; } public boolean equals(Object o) { if(! (o instanceof Person)) return false; Person p = (Person)o; return age == p.age name.equals(p.name); } } What is the appropriate definition of the hashCode method in class Person?() A、 return super.hashCode();B、 return name.hashCode() + age * 7;C、 return name.hashCode() + comment.hashCode() /2;D、 return name.hashCode() + comment.hashCode() / 2 - age * 3;
public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(String name){ System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 23B、 13C、 123D、 321
public class Pet{ private String name; public Pet(String name){ this.name = name; } public void speak(){ System.out.print(name); } } public class Dog extends Pet{ public Dog(String name){ super(name); } public void speak(){ super.speak(); System.out.print(“ Dog ”); } } 执行代码 Pet pet = new Dog(“京巴”); pet.speak(); 后输出的内容是哪项?() A、 京巴B、 京巴 DogC、 nullD、 Dog京巴
下列类Account的构造方法中,声明正确的是?() A、Account (String name)()B、Account (String name)C、Account (name)()D、NewAccount (String name)()
public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ public Manager(String name){ System.out.println(getName()); } } 执行语句new Manager(“smith”)后程序的输出是哪项?() A、 smithB、 nullC、 编译错误D、 name
文件输出流的构造方法是 public FileOutputStream(String name,Boolean append)throws FileNotFoundException,当参数append的值为true时,表示()A、创建一个新文件B、在原文件的尾部添加数据C、覆盖原文件的内容D、在原文件的指定位置添加数据ensp;RandomAccess
public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println( super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?() A、 smith,SALESB、 null,SALESC、 smith,nullD、 null,null
用文件字节输出流对文件进行写操作时,需要先创建文件输出流对象,文件输出数据流的构造方法是 public FileOutputStream(String name,Boolean append) throws FileNotFoundException,当参数append的值为true时,表示()A、创建一个新文件B、在原文件的尾部添加数据C、覆盖原文件的内容D、在原文件的指定位置添加数据
public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(){ System.out.print(4); } public Dog(String name){ this(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 143B、 423C、 243D、 1134
单选题public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(){ System.out.print(4); } public Dog(String name){ this(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()A 143B 423C 243D 1134
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println(super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A smith,SALESB null,SALESC smith,nullD null,nullE 编译错误
单选题public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(){ System.out.print(4); } public Dog(String name){ super(name); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()A 33B 13C 23D 123
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ this.department = department; super(name); System.out.println(getName()); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A smithB nullC SALESD 编译错误
单选题用文件字节输出流对文件进行写操作时,需要先创建文件输出流对象,文件输出数据流的构造方法是 public FileOutputStream(String name,Boolean append) throws FileNotFoundException,当参数append的值为true时,表示()A创建一个新文件B在原文件的尾部添加数据C覆盖原文件的内容D在原文件的指定位置添加数据
单选题public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(String name){ System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()A 23B 13C 123D 321
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ public Manager(String name){ System.out.println(getName()); } } 执行语句new Manager(“smith”)后程序的输出是哪项?()A smithB nullC 编译错误D name
单选题执行以下代码后,下面哪些描述是正确的() public class Student{ private String name = “Jema”; public void setName(String name){ this.name = name; } public String getName(){ return this.name; } public static void main(String[] args){ Student s; System.out.println(s.getName()); } }A输出nullB第10行编译报错C第11行编译报错D输出Jema
单选题public class Pet{ private String name; public Pet(String name){ this.name = name; } public void speak(){ System.out.print(name); } } public class Dog extends Pet{ public Dog(String name){ super(name); } public void speak(){ super.speak(); System.out.print(“ Dog ”); } } 执行代码 Pet pet = new Dog(“京巴”); pet.speak(); 后输出的内容是哪项?()A 京巴B 京巴 DogC nullD Dog京巴
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println( super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A smith,SALESB null,SALESC smith,nullD null,null
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ this.department = department; super(name); (应于上一行掉位置) System.out.println(getName()); } } Super的位置是否在方法的首行 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A smithB nullC SALESD 编译错误