public interface A { String DEFAULT_GREETING = “Hello World”; public void method1(); } A programmer wants to create an interface called B that has A as its parent. Which interface declaration is correct?() A、 public interface B extends A {}B、 public interface B implements A {}C、 public interface B instanceOf A {}D、 public interface B inheritsFrom A {}
public interface A { String DEFAULT_GREETING = “Hello World”; public void method1(); } A programmer wants to create an interface called B that has A as its parent. Which interface declaration is correct?()
- A、 public interface B extends A {}
- B、 public interface B implements A {}
- C、 public interface B instanceOf A {}
- D、 public interface B inheritsFrom A {}
相关考题:
A programmer needs to create a logging method that can accept an arbitrary number of arguments.Forexample,it may be called in these ways:logIt(log message 1);logIt(log message 2”,”log message 3);logIt(log message 4,log message 5,log message 6);Which declaration satisfies this requirement()?A.public void logIt(String*msgs)B.public void logIt(String[]msgs)C.public void logIt(String...msgs)D.public voidl ogIt(Stringmsg1,Stringmsg2,Stringmsg3)
Given:10. interface Data { public void load(); }11. abstract class Info { public abstract void load(); }Which class correctly uses the Data interface and Info class?()() A.B.C.D.E.F.
阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。[说明]本程序的功能是给公司的员工Tom,Jack,Green增加薪水。三人的职位分别是programmer, Manager,CEO。程序由6个类组成:WorkerTest是主类,programmer,Manager,CEO三个类,薪水增加的规则是 programmer的涨幅是5%;Manager的是10%;CEO也是Manager,但是它除了有Manager的涨幅,还有1000元的bonus。接口SalaryRaise提供了一个增加薪水的方法raise()。[java程序]public class WorkerTest {public WorkerTest( ) {}public static void main( String[] args) {Programmer programmer = new Programmer( "Tom" ,3000);Manager manager = new Manager( "Jack" ,4000);CEO ceo = new CEO( "Green" ,4000);Worker [] worker = new Worker[3];programmer, raise( );manager, raise( );ceo. raise( );worker[0] = programmer;worker [1] = manager;worker[2] = ceo;for ( int i = 0 ;i < worker, length; i + + ) {System. out. prinfln (" Name:" + worker [i]. getName ( ) +" \ tSalary:" + worker [i]. getSalary ());public interface SalaryRaise { void raise( ); }public class Worker {public String name;public double (1);public Worker( ) {}public String getName( ) {return name;}public void setName( String name) {this. name = name;}public double getSalary( ) {return salary;}public void setSalary(double salary) { this. salary = salary; }}public class Programmer extends Worker implements (2) {public Programmer( ) {}public void raise( ) {double pets=0.05;double sala = this. getSalary( ) * (1 + pers);this. setSalary (sala);public Programmer( Siring name, double salary) tthis. name = name;this. salary = salary;public class Manager extends (3) implements SalaryRaise {public Manager( ) { }public Manager(String name, double salary) {this. name = name;this. salary = salary;}public void raise( ) {double pets = 0.1;double sala = this. getSalary() * (1 + pers);this. setSalary(sala);}}public class CEO extends Manager implements SalaryRaise {public CEO() {}public CEO( String name,double salary) {this. name = name;this. salary = salary;}public void raise( ) {double bonus = 1000;(4);double sala = this. getSalary( );(5);this. setSalary(sala);}}
interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}
interface Playable {void play();}interface Bounceable {void play();}interface Rollable extends Playable, Bounceable {Ball ball = new Ball("PingPang");}class Ball implements Rollable {private String name;public String getName() {return name;}public Ball(String name) {this.name = name;}public void play() {ball = new Ball("Football");System.out.println(ball.getName());}}这个错误不容易发现。
A programmer needs to create a logging method that can accept an arbitrary number of arguments.Forexample,it may be called in these ways: logIt("log message 1"); logIt("log message 2”,”log message 3"); logIt("log message 4","log message 5","log message 6"); Which declaration satisfies this requirement()?A、public void logIt(String*msgs)B、public void logIt(String[]msgs)C、public void logIt(String...msgs)D、public voidl ogIt(Stringmsg1,Stringmsg2,Stringmsg3)
Which three demonstrate an “is a” relationship?() A、 public class X { } public class Y extends X { }B、 public interface Shape { } public interface Rectangle extends Shape{ }C、 public interface Color { } public class Shape { private Color color; }D、 public interface Species { } public class Animal { private Species species; }E、 public class Person { } public class Employee { public Employee(Person person) { }F、 interface Component { } class Container implements Component { private Component[] children; }
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*/ } }
A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways: logIt(”log message 1 “); logIt(”log message2”,”log message3”); logIt(”log message4”, “log message5”, “log message6); Which declaration satisfies this requirement?()A、 public void logIt(String * msgs)B、 public void logIt(String [] msgs)C、 public void logIt(String... msgs)D、 public void logIt(String msg1, String msg2, String msg3)
Which method must be defined by a class implementing the java.lang.Runnable interface? () A、 void run()B、 public void run()C、 public void start()D、 void run(int priority)E、 public void run(int priority)F、 public void start(int priority)
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)
现有: interface Data {public void load();} abstract class Info {public abstract void load();} 下列类定义中正确使用Data和Info的是哪项?() A、 public class Employee implements Info extends Data { public void load(){/*dosomething*/} }B、public class Employee extends Inf.implements Data{ public void load() {/*do something*/} }C、public class Empl.yee implements Inf extends Data{ public void Data.1oad(){* do something*/} public void load(){/*do something*/} }D、public class Employee extends Inf implements Data { public void Data.1oad() {/*do something*/) public void info.1oad(){/*do something*/} }
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;
interface A { public int getValue() } class B implements A { public int getValue() { return 1; } } class C extends B { // insert code here } Which three code fragments, inserted individually at line 15, make use of polymorphism?()A、 public void add(C c) { c.getValue(); }B、 public void add(B b) { b.getValue(); }C、 public void add(A a) { a.getValue(); }D、 public void add(A a, B b) { a.getValue(); }E、 public void add(C c1, C c2) { c1.getValue(); }
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; )
现有: 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 行,有多少行可以编译?() A、 0B、 1C、 2D、 3
1. interface A { public void aMethod(); } 2. interface B { public void bMethod(); } 3. interface C extends A,B { public void cMethod(); } 4. class D implements B { 5. public void bMethod() { } 6. } 7. class E extends D implements C { 8. public void aMethod() { } 9. public void bMethod() { } 10. public void cMethod() { } 11. } What is the result?() A、 Compilation fails because of an error in line 3.B、 Compilation fails because of an error in line 7.C、 Compilation fails because of an error in line 9.D、 If you define D e = new E(), then e.bMethod() invokes the version of bMethod()defined in Line 5.E、 If you define D e = (D)(new E()),then e.bMethod() invokes the version of bMethod() defined in Line 5.F、 If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
单选题public interface A { String DEFAULT_GREETING = “Hello World”; public void method1(); } A programmer wants to create an interface called B that has A as its parent. Which interface declaration is correct?()A public interface B extends A {}B public interface B implements A {}C public interface B instanceOf A {}D public interface B inheritsFrom A {}
多选题Which two demonstrate an “is a” relationship?()Apublic interface Person { } public class Employee extends Person { }Bpublic interface Shape { } public class Employee extends Shape { }Cpublic interface Color { } public class Employee extends Color { }Dpublic class Species { } public class Animal (private Species species;)Einterface Component { } Class Container implements Component ( Private Component[ ]children; )
单选题Which method must be defined by a class implementing the java.lang.Runnable interface? ()A void run()B public void run()C public void start()D void run(int priority)E public void run(int priority)F public void start(int priority)
单选题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)
多选题Which the two demonstrate an “is a” relationship?()Apublic interface Person {} Public class Employee extends Person {}Bpublic interface Shape {} public interface Rectangle extends Shape {}Cpublic interface Color {} public class Shape { private Color color; }Dpublic class Species {} public class Animal { private Species species; }Einterface Component {} Class Container implements Component {private Component [] children;
单选题现有: 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 行,有多少行可以编译?()A 0B 1C 2D 3
多选题Which three demonstrate an “is a” relationship?()Apublic class X { } public class Y extends X { }Bpublic interface Shape { } public interface Rectangle extends Shape{ }Cpublic interface Color { } public class Shape { private Color color; }Dpublic interface Species { } public class Animal { private Species species; }Epublic class Person { } public class Employee { public Employee(Person person) { }Finterface Component { } class Container implements Component { private Component[] children; }
单选题A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways: logIt(”log message 1 “); logIt(”log message2”,”log message3”); logIt(”log message4”, “log message5”, “log message6); Which declaration satisfies this requirement?()A public void logIt(String * msgs)B public void logIt(String [] msgs)C public void logIt(String... msgs)D public void logIt(String msg1, String msg2, String msg3)
多选题10. interface Jumper { public void jump(); } ...... 20. class Animal {} ...... 30. class Dog extends Animal { 31. Tail tail; 32. } ...... 40. class Beagle extends Dog implements Jumper { 41. public void jump() { } 42. } ....... 50. class Cat implements Jumper { 51. public void jump() { } 52. } Which three are true?()ACat is-a AnimalBCat is-a JumperCDog is-a AnimalDDog is-a JumperECat has-a AnimalFBeagle has-a TailGBeagle has-a Jumper
单选题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*/ } }