多选题public class OuterClass {  private double d1  1.0;  //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()Astatic class InnerOne {  public double methoda() {return d1;}  }Bstatic class InnerOne {  static double methoda() {return d1;} }Cprivate class InnerOne {  public double methoda() {return d1;} }Dprotected class InnerOne {  static double methoda() {return d1;} }Epublic abstract class InnerOne {  public abstract double methoda();  }

多选题
public class OuterClass {  private double d1  1.0;  //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()
A

static class InnerOne {  public double methoda() {return d1;}  }

B

static class InnerOne {  static double methoda() {return d1;} }

C

private class InnerOne {  public double methoda() {return d1;} }

D

protected class InnerOne {  static double methoda() {return d1;} }

E

public abstract class InnerOne {  public abstract double methoda();  }


参考解析

解析: 暂无解析

相关考题:

阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】下面的程序先构造Point类,再顺序构造Ball类。由于在类Ball中不能直接存取类Point中的xCoordinate及yCoordinate属性值,Ball中的toString方法调用Point类中的toString方法输出中心点的值。在MovingBall类的toString方法中,super.toString调用父类Ball的toString方法输出类Ball中声明的属性值。public class Point{private double xCoordinate;private double yCoordinate;public Point 0 }public Point(ouble x, double y){xCoordinate = x;yCoordinate = y;}public String toString(){return "( + Double.toString(Coordinate)+ ","+ Double.toString(Coordinate) + ");}//other methods}public class Ball{(1); //中心点private double radius; //半径private String colour; ///颜色public Ball() { }public Ball(double xValue, double yValue, double r)// 具有中心点及半径的构造方法{center=(2);//调用类Point 中的构造方法radius = r;}public Ball(double xValue, double yValue, double r, String c)// 具有中心点、半径及颜色的构造方法{(3);//调用3个参数的构造方法colour = c;}public String toString(){return "A ball with center" + center, toString() + ", radius"+ Double.toString(radius) + ", colour" + colour;}//other methods}public class MovingBall. (4){private double speed;public MovingBall() { }public MovingBall(double xValue, double yValue, double r, String e, double s){(5);// 调用父类Ball中具有4个参数的构造方法speed = s;}public String toString( ){ return super, toString( ) + ", speed "+ Double.toString(speed); }//other methods}public class Tester{public static void main(String args[]){MovingBall mb = new MovingBall(10,20,40,"green",25);System.out.println(mb);}}

( 23 )有如下两个类定义class XX{private:double x1;protected:double x2;public:double x3;};class YY:protected XX{private:double y1;protected:double y2;public:double y3;};在类 YY 中保护成员变量的个数是A ) 1B ) 2C ) 3D ) 4

阅读下列代码 public class { public static void main(String args[]){ double d=12.3; Decrementer dec=new Decrementer(); dec. decrement(D) ; System. out. println(D) ; } } class Decrementer{ public void decrement(double decMe){ decMe=decMe-1.0; } } 代码执行后输出结果是A.12.3B.11.3C.13.3D.-1.0

有如下两个类定义: class XX{ private: double X1; protected: double x2; public: doublex3; ); clase YY:protected XX{ private: doubley1; protected: doubley2; public: double y3; }; 在类YY中保护成员变量的个数是( )。A.1B.2C.3D.4

Given:Which two methods, inserted independently at line 17, correctly complete the Sales class?() A.double getSalesAmount() { return 1230.45; }B.public double getSalesAmount() { return 1230.45; }C.private double getSalesAmount() { return 1230.45; }D.protected double getSalesAmount() { return 1230.45; }

阅读以下函数说明和Java代码,将应填入(n)处的字句写在对应栏内。【说明】下面的程序先构造Point类,再顺序构造Ball类。由于在类Ball中不能直接存取类Point中的xCoordinate及yCoordinate属性值,Ball中的toString方法调用Point类中的toStrinS方法输出中心点的值。在MovingBsll类的toString方法中,super.toString调用父类Ball的toString方法输出类Ball中声明的属性值。【Java代码】//Point.java文件public class Point{private double xCoordinate;private double yCoordinate;public Point(){}public Point(double x,double y){xCoordinate=x;yCoordinate=y;}public String toStrthg(){return"("+Double.toString(xCoordinate)+","+Double.toString(yCoordinate)+")";}//other methods}//Ball.java文件public class Ball{private (1);//中心点private double radius;//半径private String color;//颜色public Ball(){}public Ball(double xValue, double yValue, double r){//具有中心点及其半径的构造方法center=(2);//调用类Point中的构造方法radius=r;}public Ball(double xValue, double yValue, double r, String c){//具有中心点、半径和颜色的构造方法(3);//调用3个参数的构造方法color=c;}public String toString(){return "A ball with center"+center.toString()+",radius "+Double.toString(radius)+",color"+color;}//other methods}class MovingBall (4) {private double speed;public MovingBall(){}public MoyingBall(double xValue, double yValue, double r, String c, double s){(5);//调用父类Ball中具有4个参数的构造方法speed=s;}public String toString(){return super.toString()+",speed"+Double.toString(speed);}//other methods}public class test{public static void main(String args[]){MovingBall mb=new MovingBall(10,20,40,"green",25);System.out.println(mb);}}

下列程序的执行结果为【 】。include class Point{public:Point(double i, double j) 下列程序的执行结果为【 】。include <iostream. h>class Point{public:Point(double i, double j) { x=i; y=j;}double Area() const { return 0.0;}private:double x, y;};class Rectangle: public Point{public:Rectangle(double i, double j, double k, double 1)double Area() const {return w * h;}private:double w, h;};Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j).{w=k, h=1}void fun(Point s){cout<<s. Area()<<end1;}void main( ){Rectangle rec(3.0, 5.2, 15.0. 25.0);fun(rec)}

下列选项成员变量声明正确的是A.public protected final int i;B.abstract class F1{…}C.private double height;D.double weight{}

下列成员变量声明中,正确的是______。A.public protected final int i;B.abstract class F1{…}C.private double height;D.double weight

有以下程序:includeusing namespace std;class sample{private:int x;public:sample( 有以下程序: #include<iostream> using namespace std; class sample { private: int x; public: sample(int A) { x=a; friend double square(sample s); }; double square(sample s) { return S.X*S.K; } int main() { saA.20B.30C.900D.400

下列选项成员变量声明正确的是( )。A.public protected final int i;B.abstract class Fl{…}C.private double height;D.double weight

有以下程序:includeincludeusing namespace std; class point{private:double 有以下程序: #include<iostream> #include<math> using namespace std; class point { private: double x; double y; public: point(double a,double B) { x=a; y=b; } friend double distance (point a,point B) ;A.1B.5C.4D.6

有如下两个类定义: class XX{ private: double xl; protected: double x2; public: double x3; }; class YY:protected XX{ private: double yl; protected: double y2; public: double y3; 在类YY中保护成员变量的个数是( )。A.1B.2C.3D.4

阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。【说明】某大型购物中心欲开发一套收银软件,要求其能够支持购物中心在不同时期推出的各种促销活动,如打折、返利(例如,满300返100)等等。现采用策略(Strategy)模式实现该要求,得到如图6-1所示的类图。import javA.util.*;enum TYPE {NORMAL, CASH_DISCOUNT, CASH_RETURN};interfaceCashSuper { public (1) ;}class CashNormalimplements CashSuper{ // 正常收费子类 public double accptCash(double money){ return money; }}classCashDiscount implements CashSuper { private double moneyDiscount; // 折扣率 public CashDiscount(double moneyDiscount) { this moneyDiscount = moneyDiscount; } public double acceptCash(double money) { return money* moneyDiscount; }}class CashReturnimplements CashSuper { // 满额返利 private double moneyCondition; private double moneyReturn; public CashReturn(double moneyCondition, double moneyReturn) { this.moneyCondition =moneyCondition; // 满额数额 this.moneyReturn =moneyReturn; // 返利数额 } public double acceptCash(double money) { double result = money; if(money >= moneyCondition ) result=money-Math.floor(money/moneyCondition ) *moneyReturn; return result; }}classCashContext_{ private CashSuper cs; private TYPE t; public CashContext(TYPE t) { switch(t){ case NORMAL: // 正常收费 (2) ; break; case CASH_DISCOUNT: // 满300返100 (3) ; break; case CASH_RETURN: // 打8折 (4) ; break; } } public double GetResult(double money) { (5) ; } ∥此处略去main( )函数}

1. class BaseClass {  2. private float x = 1.of;  3. protected float getVar() { return x; }  4. }  5. class SubClass extends BaseClass {  6. private float x = 2.Of;  7. // insert code here 8. }   Which two are valid examples of method overriding when inserted at line 7?() A、 float getVar() { return x; }B、 public float getVar() { return x; }C、 public double getVar() { return x; }D、 protected float getVar() { return x; }E、 public float getVar(float f) { return f; }

Which will declare a method that is available to all members of the same package and can be referenced  without an instance of the class?()  A、 Abstract public void methoda();B、 Public abstract double methoda();C、 Static void methoda(double d1){}D、 Public native double methoda(){}E、 Protected void methoda(double d1){}

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; }

10. abstract public class Employee {  11. protected abstract double getSalesAmount();  12. public double getCommision() {  13. return getSalesAmount() * 0.15;  14. }  15. }  16. class Sales extends Employee {  17. // insert method here  18. }  Which two methods, inserted independently at line 17, correctly complete the Sales class?()A、 double getSalesAmount() { return 1230.45; }B、 public double getSalesAmount() { return 1230.45; }C、 private double getSalesAmount() { return 1230.45; }D、 protected double getSalesAmount() { return 1230.45; }

public class OuterClass {  private double d1  1.0;  //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?() A、 static class InnerOne {  public double methoda() {return d1;}  }B、 static class InnerOne {  static double methoda() {return d1;} }C、 private class InnerOne {  public double methoda() {return d1;} }D、 protected class InnerOne {  static double methoda() {return d1;} }E、 public abstract class InnerOne {  public abstract double methoda();  }

class BaseClass{  private float x= 1.0f;  protected void setVar (float f) {x = f;}  }  class SubClass extends BaseClass   {  private float x = 2.0f;  //insert code here  }   Which two are valid examples of method overriding?()        A、 Void setVar(float f) {x = f;}B、 Public void setVar(int f) {x = f;}C、 Public void setVar(float f) {x = f;}D、 Public double setVar(float f) {x = f;}E、 Public final void setVar(float f) {x = f;}F、 Protected float setVar() {x=3.0f; return 3.0f; }

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;

1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()  A、 static class InnerOne { public double methoda() { return d1; } }B、 static class InnerOne { static double methoda() { return d1; } }C、 private class InnerOne { public double methoda() { return d1; } }D、 protected class InnerOne { static double methoda() { return d1; } }E、 public abstract class InnerOne { public abstract double methoda(); }

public class Car {  private int wheelCount;  private String vin;  public Car(String vin) {  this.vin = vin;  this.wheelCount = 4;  }  public String drive() {  return “zoom-zoom”;  }  public String getInfo() {  return “VIN: “+ vin + “wheels: “+ wheelCount;  }  }  And:  public class MeGo extends Car {  public MeGo(String vin) {  this.wheelCount = 3;  }  }  What two must the programmer do to correct the compilation errors?()A、 insert a call to this() in the Car constructorB、 insert a call to this() in the MeGo constructorC、 insert a call to super() in the MeGo constructorD、 insert a call to super(vin) in the MeGo constructorE、 change the wheelCount variable in Car to protectedF、 change line 3 in the MeGo class to super.wheelCount = 3;

public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

单选题Which will declare a method that is available to all members of the same package and can be referenced without an instance of the class?()A Abstract public void methoda();B Public abstract double methoda();C Static void methoda(double d1){}D Public native double methoda()  {}E Protected void methoda(double d1)  {}

多选题1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()Astatic class InnerOne { public double methoda() { return d1; } }Bstatic class InnerOne { static double methoda() { return d1; } }Cprivate class InnerOne { public double methoda() { return d1; } }Dprotected class InnerOne { static double methoda() { return d1; } }Epublic abstract class InnerOne { public abstract double methoda(); }

多选题public class OuterClass {   private double d1 1.0;   //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()Astatic class InnerOne {  public double methoda() {return d1;}  }Bstatic class InnerOne {  static double methoda() {return d1;}  }Cprivate class InnerOne {  public double methoda() {return d1;}  }Dprotected class InnerOne {  static double methoda() {return d1;}  }Epublic abstract class InnerOne {  public abstract double methoda();  }

多选题10. abstract public class Employee {  11. protected abstract double getSalesAmount();  12. public double getCommision() {  13. return getSalesAmount() * 0.15;  14. }  15. }  16. class Sales extends Employee {  17. // insert method here  18. }  Which two methods, inserted independently at line 17, correctly complete the Sales class?()Adouble getSalesAmount() { return 1230.45; }Bpublic double getSalesAmount() { return 1230.45; }Cprivate double getSalesAmount() { return 1230.45; }Dprotected double getSalesAmount() { return 1230.45; }