网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
现有: class Pencil { public void write (String content){ System.out.println( "Write",+content){ } }class RubberPencil extends Pencil{ public void write (String content){ System.out.println("Rubber Write"+content); } public void erase (String content)}} 执行下列代码的结果是哪项?() Pencil pen=new Pencil(); (( RubberPencil) pen).write( "Hello");
A
Write Hello
B
Rubber Write Hello
C
编译失败
D
运行时抛出异常
参考答案
参考解析
解析:
暂无解析
更多 “单选题现有: class Pencil { public void write (String content){ System.out.println( "Write",+content){ } }class RubberPencil extends Pencil{ public void write (String content){ System.out.println("Rubber Write"+content); } public void erase (String content)}} 执行下列代码的结果是哪项?() Pencil pen=new Pencil(); (( RubberPencil) pen).write( "Hello");A Write HelloB Rubber Write HelloC 编译失败D 运行时抛出异常” 相关考题
考题
Which declarations will allow a class to be started as a standalone program?() A、public void main(String args[])B、public void static main(String args[])C、public static main(String[] argv)D、final public static void main(String [] array)E、public static void main(String args[])
考题
现有: class Pencil { public void write (String content){ System.out.println ("Write"+content); } } class RubberPencil extends Pencil{ public void write (String content){ System.out.println ("Rubber Write"+content); } public void erase (String content){ System.out.println ("Erase "+content); } } 执行下列代码的结果是哪项?() Pencil pen=new RubberPencil(); pen.write("Hello"); A、 Write HelloB、 Rubber Write HelloC、编译错误D、运行时抛出异常
考题
Public class test ( Public static void main (String args[]) ( System.out.printIn (6 ^ 3); ) ) What is the output?()
考题
Public class test ( Public static void stringReplace (String text) ( Text = text.replace (‘j’ , ‘i’); ) public static void bufferReplace (StringBuffer text) ( text = text.append (“C”) ) public static void main (String args[]} ( String textString = new String (“java”); StringBuffer text BufferString = new StringBuffer (“java”); stringReplace (textString); BufferReplace (textBuffer); System.out.printLn (textString + textBuffer); ) ) What is the output?()
考题
Which two allow the class Thing to be instantiated using new Thing()?A、 public class Thing { }B、 public class Thing { public Thing() {} }C、 public class Thing { public Thing(void) {} }D、 public class Thing { public Thing(String s) {} }E、 public class Thing { public void Thing() {} public Thing(String s) {} }
考题
现有: class TestApp{ public static void main (String[] args){ for (int i=0; iA、0123B、012456789C、0123456789D、012
考题
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 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(); }
考题
现有: class Pencil { public void write (String content){ System.out.println( "Write",+content){ } }class RubberPencil extends Pencil{ public void write (String content){ System.out.println("Rubber Write"+content); } public void erase (String content)}} 执行下列代码的结果是哪项?() Pencil pen=new Pencil(); (( RubberPencil) pen).write( "Hello"); A、Write HelloB、Rubber Write HelloC、编译失败D、运行时抛出异常
考题
public class Plant { private String name; public Plant(String name) { this.name = name; } public String getName() { return name; } } public class Tree extends Plant { public void growFruit() { } public void dropLeaves() { } } Which is true?() A、 The code will compile without changes.B、 The code will compile if public Tree() { Plant(); } is added to the Tree class.C、 The code will compile if public Plant() { Tree(); } is added to the Plant class.D、 The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E、 The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.
考题
现有: class Pencil { public void write (String content){ System.out.println ("Write"+content); } } class RubberPencil extends Pencil{ public void erase (String content){ System.out.println ("Erase"+content); } } 执行下列代码的结果是哪项?() Pencil pen=new RubberPencil(); pen.write ("Hello"); pen.erase ("Hello"); A、 Write Hello Erase HelloB、 Erase Hello Write HelloC、编译错误D、运行时抛出异常
考题
现有: class TestA { public void start() { System.out.println("TestA"); } } public class TestB extends TestA { public void start() { System.out.println("TestB"); } public static void main (string[] args) ( ((TestA)new TestB()).start(); ) } 运行结果是哪项?() A、 TeStAB、 TeStBC、编译失败D、运行时抛出异常
考题
现有 public class Parentt public void change (int x){) ) public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?() A、 protected void change (int x){}B、 public void change(int x, int y){}C、 public void change (int x){}D、 public void change (String s){}
考题
多选题Which declarations will allow a class to be started as a standalone program?()Apublic void main(String args[])Bpublic void static main(String args[])Cpublic static main(String[] argv)Dfinal public static void main(String [] array)Epublic static void main(String args[])
考题
单选题现有: class Pencil { public void write (String content){ System.out.println ("Write"+content); } } class RubberPencil extends Pencil{ public void erase (String content){ System.out.println ("Erase"+content); } } 执行下列代码的结果是哪项?() Pencil pen=new RubberPencil(); pen.write ("Hello"); pen.erase ("Hello");A
Write Hello Erase HelloB
Erase Hello Write HelloC
编译错误D
运行时抛出异常
考题
单选题Which method implementations will write the given string to a file named "file", using UTF8 encoding?() IMPLEMENTATION a: public void write(String msg) throws IOException { FileWriter fw = new FileWriter(new File("file")); fw.write(msg); fw.close(); } IMPLEMENTATION b: public void write(String msg) throws IOException { OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("file"), "UTF8"); osw.write(msg); osw.close(); } IMPLEMENTATION c: public void write(String msg) throws IOException { FileWriter fw = new FileWriter(new File("file")); fw.setEncoding("UTF8"); fw.write(msg); fw.close(); } IMPLEMENTATION d: public void write(String msg) throws IOException { FilterWriter fw = FilterWriter(new FileWriter("file"), "UTF8"); fw.write(msg); fw.close(); } IMPLEMENTATION e: public void write(String msg) throws IOException { OutputStreamWriter osw = new OutputStreamWriter( new OutputStream(new File("file")), "UTF8" ); osw.write(msg); osw.close(); }A
Implementation a.B
Implementation b.C
Implementation c.D
Implementation d.E
Implementation e.
考题
多选题Which two allow the class Thing to be instantiated using new Thing()?Apublic class Thing { }Bpublic class Thing { public Thing() {} }Cpublic class Thing { public Thing(void) {} }Dpublic class Thing { public Thing(String s) {} }Epublic class Thing { public void Thing() {} public Thing(String s) {} }
考题
填空题Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object. class Base { public void print( ) { System.out.println("base"); } } class Extention extends Base { public void print( ) { System.out.println("extension"); // insert line of implementation here } } public class Q294d { public static void main(String args[]) { Extention ext = new Extention( ); ext.print( ); } } Fill in a single line of implementation.()
考题
多选题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?()Apublic void aMethod() {}Bprivate void aMethod() {}Cpublic void aMethod(String s) {}Dprivate Y aMethod() { return null; }Epublic X aMethod() { return new Y(); }
考题
单选题现有 public class Parentt public void change (int x){) ) public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?()A
protected void change (int x){}B
public void change(int x, int y){}C
public void change (int x){}D
public void change (String s){}
考题
单选题public class Plant { private String name; public Plant(String name) { this.name = name; } public String getName() { return name; } } public class Tree extends Plant { public void growFruit() { } public void dropLeaves() { } } Which is true?()A
The code will compile without changes.B
The code will compile if public Tree() { Plant(); } is added to the Tree class.C
The code will compile if public Plant() { Tree(); } is added to the Plant class.D
The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E
The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.
考题
单选题现有: class Pencil { public void write (String content){ System.out.println ("Write"+content); } } class RubberPencil extends Pencil{ public void write (String content){ System.out.println ("Rubber Write"+content); } public void erase (String content){ System.out.println ("Erase "+content); } } 执行下列代码的结果是哪项?() Pencil pen=new RubberPencil(); pen.write("Hello");A
Write HelloB
Rubber Write HelloC
编译错误D
运行时抛出异常
考题
填空题Public class test ( Public static void stringReplace (String text) ( Text = text.replace („j„ , „i„); ) public static void bufferReplace (StringBuffer text) ( text = text.append (“C”) ) public static void main (String args ){ String textString = new String (“java”); StringBuffer text BufferString = new StringBuffer (“java”); stringReplace (textString); BufferReplace (textBuffer); System.out.printIn (textString + textBuffer); } ) What is the output?()
考题
单选题现有: class TestA { public void start() { System.out.println("TestA"); } } public class TestB extends TestA { public void start() { System.out.println("TestB"); } public static void main (string[] args) ( ((TestA)new TestB()).start(); ) } 运行结果是哪项?()A
TeStAB
TeStBC
编译失败D
运行时抛出异常
考题
单选题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
考题
单选题class Parent { String one, two; public Parent(String a, String b){ one = a; two = b; } public void print(){ System.out.println(one); } } public class Child extends Parent { public Child(String a, String b){ super(a,b); } public void print(){ System.out.println(one + " to " + two); } public static void main(String arg[]){ Parent p = new Parent("south", "north"); Parent t = new Child("east", "west"); p.print(); t.print(); } } Which of the following is correct?()A
Cause error during compilation. B
south east C
south to north east to west D
south to north east E
south east to west
考题
单选题现有: class TestApp{ public static void main (String[] args){ for (int i=0; i
A
0123B
012456789C
0123456789D
012
热门标签
最新试卷