单选题10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?()A Point p = Line.getPoint();B Line.Point p = Line.getPoint();C Point p = (new Line()).getPoint();D Line.Point p = (new Line()).getPoint();

单选题
10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?()
A

 Point p = Line.getPoint();

B

 Line.Point p = Line.getPoint();

C

 Point p = (new Line()).getPoint();

D

 Line.Point p = (new Line()).getPoint();


参考解析

解析: 暂无解析

相关考题:

在如下源代码文件Test.java中, 哪个是正确的类定义?() A.public class test { public int x = 0; public test(int x) { this.x = x; } }B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }D.public class

有如下类定义:class Point{public:Point(int xx=0,int yy=0):x(xx),y(yy) { }private:int x,y;};class Circle:public Point{public:Circle(int r):radius(r) { }private:int radius;};派生类Circle中数据成员的个数是( )。A、3B、1C、5D、2

阅读下列C++程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】Point是平面坐标系上的点类,Line是从Point派生出来的直线类。include <iostream.h>class Point{public:Point (int x, int y) ;Point (Point p) ;~Point();void set (double x, double y) ;void print();private:double X,Y;};Point::Point (int x, int y) //Point 构造函数{X=x; Y=y; }Point::Point ( (1) ) //Point 拷贝构造函数{X=p.X; Y=p.Y;}void Point::set (double x, double y){X=x; Y=y; }void Point::print(){cout<<' ('<<X<<","<<Y<<") "<<endl; }Point::~Point(){cout<<"Point 的析构函数被调用! "<<endl;class Line: public Point{public:Line (int x, int y, int k) ;Line (Line s) ;~Line();void set (double x, double y, double k)void print();private:double K;};(2)//Line 构造函数实现{ K=k;}(3)//Line 拷贝构造函数实现{K=s.K;}void Line::set (double x, double y, double k){ (4);K=k;}void Line::print(){cout<<" 直线经过点";(5);cout<<"斜率为: k="<<K<<endl;}Line: :~Line(){cout<<"Line 析构函数被调用! "<<endl;}void main(){Line 11 (1,1,2) ;11 .print();Linel2 (11) ;12.set (3,2,1) ;12.print();}

有如下程序: include using namespace std; class Point{ int x, y; public: Point(i 有如下程序:#include<iostream>using namespace std;class Point{int x, y;public:Point(int x1=0, int y1=0):x(x1), y(y1){}int get(){return x+y;)};class Circle{Point center;int radius;public:Circle(int CX, int cy, int r):center(cx, cy), radius(r){}int get(){return center. get()+radius;}};int main(){circle c(3, 4, 5);cout<<c. get()<<end1;return ():}运行时的输出结果是( )。A) 5B) 7C) 9D) 12A.B.C.D.

有以下程序:includeusingnamespacestd;definePI3.14classPoint{private: intx,y;pub 有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; } int gety() { return y; } }; class Circle : public Point { private: int r; public: Circle(int a,int b,int c):Point(a,b) { r=c; } int getr() { return r; } double area() { return PI*r*r; } }; int main() { Circle c1(5,7,10); cout<<cl.area()<<endl; return 0; } 程序执行后的输出结果是A.314B.157C.78.5D.153.86

有以下程序:includeusing namespace std;definePl 3.14Class Point{private:int x,y 有以下程序: #include<iostream> using namespace std; #definePl 3.14 Class Point {private: int x,y; public: Point(int a,intB) {X=a; y:b;} int getx() <return x;} int gety() {return y;}}; class Circle:public Point {priA.314B.157C.78.5D.153.86

有如下程序: include class x { protected: int a; public:x(){ a=1;} }; class x 有如下程序: #include <iostream.h> class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<a; } }; class x2 : virtual public x { public: x2() { a+=2; cout<<a; } }; class y : public xl,public x2 { public: y() { cout<<a<<end1; } }; int main() { y obj; return O; } 该程序运行后的输出结果是( )。A.1B.123C.242D.244

在下面的例子里using System;class A{public A(){PrintFields();}public virtual void PrintFields(){}}class BA{int x=1;int y;public B(){y=-1;}public override void PrintFields(){Console.WriteLine(x={0},y={1},x,y);}当使用new B()创建B的实例时,产生什么输出?

若有以下程序:include using namespace std;define PI 3.14class Point{private: in 若有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; } int gety() { return y; } }; class Circle : public Point { private: int r; public: Circle(int a, int b,int c) :Point(a,b) { r=c; } int getr() { return r; } double area() { return PI*r*r; } }; int main() { Circle c1(5,7,10); cout<<c1.area()<<end1; return 0; } 程序执行后的输出结果是( )。A.314B.157C.78.5D.153.86

有以下程序:include using namespace std;define PI 3.14class Point{ private:int 有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; }A.314B.157C.78.5D.153.86

下面程序输出的结果是( )。 include using namespace std; class A{ 下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ int X; public: A(int x):x(++x){} ~A(){cout<<x;} }; class B:public A{ int y; public: B(int y):A(y),y(y){} ~B(){cout<<y;}; }; void main(){ B b(3); }A.34B.43C.33D.44

在下列源代码文件Test.java中, ( )是正确的类定义。A.public class test{B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }C.public class Test extends T1,T2{D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}

若有以下程序:include using namespace std;class point{private: int x, y;public: 若有以下程序: #include <iostream> using namespace std; class point { private: int x, y; public: point ( ) { x=0; y=0; } void setpoint(int x1,int y1) { x=x1; y=y1;A.12,12B.5,5C.12,5D.5,12

根据程序中的注释将下列缺失部分补充完整。class Point{int x,y; //点的x和y坐标public:Point(int xx=0,int yy=0):x(xx),y(yy){}};class Circle{Point center;//圆心位置int radius; //半径public: //利用cx和cY分别初始化圆心的x和y坐标circle(int cx,int cy,int r): 【 】 ,radius(r){}void area()(cout3.14159*radius*radiusend1;)};

试完成下述程序片段:public class Point(){ int x,y;public Point(int x,int y){ =x; =y;}......} A. Point.x Point.yB.无解C. x1 y1D.this.x this.y

10. class Line {  11. public static class Point { }  12. }  13.  14. class Triangle {  15. // insert code here  16. }  Which code, inserted at line 15, creates an instance of the Point class defined in Line?() A、 Point p = new Point();B、 Line.Point p = new Line.Point();C、 The Point class cannot be instatiated at line 15.D、 Line 1 = new Line() ; 1.Point p = new 1.Point();

What produces a compiler error?()  A、 class A { public A(int x) {} }B、 class A {} class B extends A { B() {} }C、 class A { A() {} } class B { public B() {} }D、 class Z { public Z(int) {} } class A extends Z {}

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 */ } }

10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?() A、 Point p = Line.getPoint();B、 Line.Point p = Line.getPoint();C、 Point p = (new Line()).getPoint();D、 Line.Point p = (new Line()).getPoint();

多选题Which are syntactically valid statement at// point x?()     class Person {     private int a;  public int change(int m){  return m;  }     }  public class Teacher extends Person {     public int b;  public static void main(String arg[]){     Person p = new Person();     Teacher t = new Teacher();    int i;  // point x     }    }Ai = m;Bi = b;Ci = p.a;Di = p.change(30);Ei = t.b.

单选题10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  Which code, inserted at line 15, allows the class Sprite to compile?()A Foo { public int bar() { return 1; } }B new Foo { public int bar() { return 1; } }C newFoo() { public int bar(){return 1; } }D new class Foo { public int bar() { return 1; } }

多选题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?()Apublic class Circle implements Shape { private int radius; }Bpublic abstract class Circle extends Shape { private int radius; }Cpublic class Circle extends Shape { private int radius; public void draw(); }Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }Epublic class Circle extends Shape { private int radius;public void draw() {/* code here */} }Fpublic abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

单选题10. class Line {  11. public static class Point { }  12. }  13.  14. class Triangle {  15. // insert code here  16. }  Which code, inserted at line 15, creates an instance of the Point class defined in Line?()A Point p = new Point();B Line.Point p = new Line.Point();C The Point class cannot be instatiated at line 15.D Line 1 = new Line() ; 1.Point p = new 1.Point();

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

单选题1. public class Boxer1 {  2. Integer i;  3. int x;  4. public Boxer1(int y) {  5. x=i+y;  6. System.out.println(x);  7. }  8. public static void main(String[] args) {  9. new Boxer1(new Integer(4));  10. }  11. }  What is the result?()A The value “4” is printed at the command line.B Compilation fails because of an error in line 5.C Compilation fails because of an error in line 9.D A NullPointerException occurs at runtime.E A NumberFormatException occurs at runtime.F An IllegalStateException occurs at runtime.

单选题1. import java.io.*;  2. public class Foo implements Serializable {  3. public int x, y;  4. public Foo( int x, int y) { this.x = x; this.y = y; }  5.  6. private void writeObject( ObjectOutputStream s)  7. throws IOException {  8. s.writeInt(x); s.writeInt(y)  9. }  10.  11. private void readObject( ObjectInputStream s)  12. throws IOException, ClassNotFoundException {  13.  14. // insert code here  15.  16. }  17. }  Which code, inserted at line 14, will allow this class to correctly serialize and deserialize?()A s.defaultReadObject();B this = s.defaultReadObject();C y = s.readInt(); x = s.readInt();D x = s.readInt(); y = s.readInt();

多选题1. class Super {  2. private int a;  3. protected Super(int a) { this.a = a; }  4. }  .....  11. class Sub extends Super {  12. public Sub(int a) { super(a); }  13. public Sub() { this.a= 5; }  14. }  Which two, independently, will allow Sub to compile?()AChange line 2 to: public int a;BChange line 2 to: protected int a;CChange line 13 to: public Sub() { this(5); }DChange line 13 to: public Sub() { super(5); }EChange line 13 to: public Sub() { super(a); }