给定如下Java代码,以下()修饰符可以填入下划线处 class Parent{ protected void eat(){} } class Child extends Parent{ ______ void eat(){} }A.finalB.staticC.privateD.public

给定如下Java代码,以下()修饰符可以填入下划线处 class Parent{ protected void eat(){} } class Child extends Parent{ ______ void eat(){} }

A.final

B.static

C.private

D.public


参考答案和解析
private

相关考题:

下列选项中的 方法可以正确地加入类Child中,且父类的方法不会被覆盖。 public class Parent{ public int addValue(int a,int b){ int s; s=a+b; return s; } } class Child extends Parent{ }A.int addValue(int a,int b){∥do something…}B.public void addValue( ){∥do something…}C.public int addValue(int a,int b)throws MyException{∥do something…}D.public float addValue(int a,int b,float b=1.0){∥do something…}

下列代码的下划线处应填入的方法名是______。import java.awt.*;import java.applet.*;public class Hello extends Applet{public void______(Graphics g){g.drawString("How are you!", 10, 10);}}A) repaintB) printlnC) paintD) showA.B.C.D.

有如下程序段: public class Parent { public int addValue (int a,intB){ int s; s=a+b; return 3; } } class Child extends Parent {} 则下列选项中,可以正确加入类Child中且父类的方法不会被覆盖的是( )。A.int addValue (int a,intB){//do something...}B.public void addValue() {//do something...}C.public int addValue (int a,intB)throws MyException {//do something...}D.public float addValue (int a,int b,float b=1.0) {//do someting...}

下列程序构造了一个 Swing Applet ,请在下划线处填入正确的代码Import javax.swing.*;Import java.awt.*;Public class SwingApplet extends 【 13 】 {Jlabel l = new Jlabel ( “ This is a Swing Applet. ” );Public void init(){Container contentPane = getContentPane();contentPane.add(1);}}

已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?() A.private void fun( int n ){ //...}B.void fun ( int n ){ //... }C.protected void fun ( int n ) { //... }D.public void fun ( int n ) { //... }

下面程序是关于类的继承的用法。阅读下面程序,根据程序中的注释在每一条横线处填写一个语句,使程序的功能完整,且运行程序后的输出结果为:I am parentclass!I am childclass!I am childclass!注意: 请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。class Parent {void printMe() {System.out.println("I am parentclass!");}}class Child extends Parent {void printMe() {System.out.println("I am childclass!");}void printAll() {______________.printMe ( ); // 调用父类的方法______________. printMe ( ); //调用本类的方法printMe ( );}}public class TestJieCheng {public static void main(String args[]) {______________myC.printAll();}}

阅读以下说明和Jrdva代码,将应填入(n)处的字句写在对应栏内。[说明]在销售系统中常常需要打印销售票据,有时需要在一般的票据基础上打印脚注。这样就需要动态地添加一些额外的职责。如下展示了Decorator(修饰)模式。SalesOrder对象使用一个SalesTicket对象打印销售票据。图6-1显示了各个类间的关系。以下是Java语言实现,能够正确编译通过。[图6-1][Java代码]//Component.java文件public (1) class Component {abstract publ ic void prtTicket();}//salesTicket.java文件public class SalesTicket extends Component{public void prtTicket(){//Sales ticket printing code hereSystem.out.printin("SalesTicket");}}//Decorator.java文件publ ic abstract class Decorator extends Component{public void prtTicket(){if(myComp!=null)myComp.prtTicket();}private (2) myComp;public Decorator(Component myC){myComp=myC;}}//Footer.java文件public class Footer extends Decorator {public Footer(Component myC){(3);}public void prtTicket(){(4);prtFooter();}publ ic void prtFooter(){//place printing footer code hereSystem.out.println("Footer");}}//salesorder.java文件public class SalesOrder{void prtTicket(){Component myST;myST=new Footer( (5) );//Print Ticket with footers as neededmyST.prtTicket();}}(1)

下列代码的输出结果是( )。class parent{void printme(){System.out.println("parent");}}class child extends parent{void printme(){System. out.println("child");}void printall(){super, printme();this.printme();printme();}}public class test{public static void main(String args[]){child myc=new child();myc.printall();}}A.import java.awt.*;B.import java.applet.applet;C.import java.io.*;D.import java, awt.graphics;

下列代码的下画线处应填入的方法名是( )。 import java.awt.*; import java.applet.*; public class Hello extends Applet{ public void (Graphics g){ 9.drawstring("How are you!",l0,10); } }A.repaintB.printlnC.paintD.show

试题六(共15分)阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。【说明】某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰( Decorator)模式实现打印发票的功能,得到如图6-1所示的类图。【java代码】class invoice{public void printInvoice(){:System.out.println ( This is the content of the invoice!);}}class Decorator : extends Invoice {protected Invoice ticket;public Decorator(lnvoice t){ticket = t;}public void printinvoice(){if(ticket != NULL)(1);}}class FootDecorator extends Decorator{public FootDecorator(lnvoice t){super(t);}public void printinvoice (){Systent.out.println( This is the header of the invoice! );(2) ;}}class FootDecorator extends Decorator {public FootDecorator(invoice t):{super(t);}public void printlnvoice(){(3) ;Systent.out.println( This is the header of the invoice! );}}Class test {public static void main(string[] args){Invoice t =new invioce();Invoice ticket;Ticket= (4) ;Ticket. Printinvoice();Systent.out.println(“--------------“)Ticket= (5) ;Ticket. Printinvoice();}}程序的输出结果为:This is the header of the invoice!This is the content of the invoice!This is the footnote of the invoice!----------------------------This is the header of the invoice!This is the footnote of the invoice!

下列程序创建了一个线程并运行,请在下划线处填入正确代码。public class Try extends Thread{public static void main(String args[]){Threadt=new Try();【 】;}public void run(){System.out.println(“Try!”);}}

请在下划线处填入代码,使程序能够正确运行。import java .awt.*;import java .applet.*;public class SayHi extends Applet{public void【 】(Graphics g){g .drawString(“Hi!”20,20);}}

( 8 )在下列 Java applet 程序的横线处填入代码,使程序完整并能够正确运行。Import java. awt. *;Import java. applet. *;Public class Greeting extends applet{Public void 【 8 】 (Graphics g) {g.drawSting( “ how are you! ” ,10,10);}}

interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?() A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }

以下哪句可以获取到class为“child";的元素的父级元素?()A、$(".child:parent")B、$(".child").parentNode()C、$(".child"):parentD、$(".child").parent()

Given the following code:     1) class Parent {     2) private String name;     3) public Parent(){}     4) }  5) public class Child extends Parent {     6) private String department;  7) public Child() {}  8) public String getValue(){ return name; }     9) public static void main(String arg[]) {     10) Parent p = new Parent();     11) }  12) }  Which line will cause error?()   A、 line 3B、 line 6C、 line 7D、 line 8E、 line 10

现有      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 Parent {     int change() {…}     }  class Child extends Parent {     }  Which methods can be added into class Child?()Apublic int change(){}Bint chang(int i){}Cprivate int change(){}Dabstract int chang(){}

单选题public class Parent{     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(String s){}D public void change(int x){}

单选题现有      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){}

单选题现有:  1. interface Animal {  2. void eat();  3. }  4.  5. // insert code here  6.  7. public class HouseCat extends Feline {  8. public void eat() { }  9. }   和五个声明:  abstract class Feline implements Animal { }  abstract class Feline implements Animal { void eat(); }  abstract class Feline implements Animal { public void eat(); }  abstract class Feline implements Animal { public void eat() { } }  abstract class Feline implements Animal { abstract public void eat(); }  分别插入到第5行,有几个可以通过编译?()A0B1C2D3

单选题Given the following code:     1) class Parent {     2) private String name;     3) public Parent(){}     4) }  5) public class Child extends Parent {     6) private String department;  7) public Child() {}  8) public String getValue(){ return name; }     9) public static void main(String arg[]) {     10) Parent p = new Parent();     11) }  12) }  Which line will cause error?()A line 3B line 6C line 7D line 8E line 10

多选题public class Parent {  public int addValue( int a, int b) {     int s;     s = a+b;     return s;     }     }  class Child extends Parent {  }  Which methods can be added into class Child?()Aint addValue( int a, int b ){// do something...}Bpublic void addValue (){// do something...}Cpublic int addValue( int a ){// do something...}Dpublic int addValue( int a, int b )throws MyException {//do something...}

单选题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

单选题现有:  1.  interface Animal  f      2.    void eat();      3.    }      4.  5.  // insert code here      6.  7. public class HouseCat implements Feline  {      8.    public void eat()    {  }     9.  }  和以下三个接口声明:  interface Feline extends Animal  (  )  interface Feline extends Animal  {void eat();    }  interface Feline extends Animal  {void eat()    {  }  }   分别插入到第5行,有多少行可以编译?A  0B  1C  2D  3

单选题现有:  interface Animal {       void eat () ;       }       //insert code here       public class HouseCat extends Feline {       public void eat() { }       }  和五个申明  abstract class Feline implements Animal { }  abstract  class  Feline  implements  Animal  {  void eat () ;  }  abstract class Feline implements Animal { public void eat();}  abstract class Feline implements Animal { public void eat() {}  }  abstract class Feline implements Animal { abstract public void eat();} 结果为:()A1B2C3D4

单选题1. interface Animal {   2. void eat();   3. }   4.   5. // insert code here   6.   7. public class HouseCat implements Feline {   8. public void eat() { }   9. }   和以下三个接口声明:   interface Feline extends Animal { }   interface Feline extends Animal { void eat(); }   interface Feline extends Animal { void eat() { } }   分别插入到第 5 行,有多少行可以编译?()A0B1C2D3

单选题以下哪句可以获取到class为“child";的元素的父级元素?()A$(.child:parent)B$(.child).parentNode()C$(.child):parentD$(.child).parent()