Line l = new Line() ; l.Point p = new l.Point();
Line.Point p = new Line.Point();
The Point class cannot be instatiated at line 15.
Point p = new Point();
第1题:
A.The application will crash.
B.The code on line 29 will be executed.
C.The code on line 5 of class A will execute.
D.The code on line 5 of class B will execute.
E.The exception will be propagated back to line 27.
第2题:
A.Point p = Line.getPoint();
B.Line.Point p = Line.getPoint();
C.Point p = (new Line()).getPoint();
D.Line.Point p = (new Line()).getPoint();
第3题:
阅读下列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();
}
第4题:
Given the following code fragment: public void create() { Vector myVect; myVect = new Vector(); } Which of the following statements are true?()
第5题:
class Super { public int getLenght( ) { return 4; } } public class Sub extends Super { public long getLenght( ) { return 5; } public static void main(String[] args) { Super sooper = new Super( ); Sub sub = new Sub( ); System.out.println( sooper.getLenght( ) + “,” + sub.getLenght( ) ); } } What is the output?()
第6题:
A.Foo { public int bar() { return 1; }
B.new Foo { public int bar() { return 1; }
C.new Foo() { public int bar() { return 1; }
D.new class Foo { public int bar() { return 1; }
第7题:
1. public class Outer{ 2. public void someOuterMethod() { 3. // Line 3 4. } 5. public class Inner{} 6. public static void main( String[]argv ) { 7. Outer o = new Outer(); 8. // Line 8 9. } 10. } Which instantiates an instance of Inner?()
第8题:
A.Point p = new Point();
B.Line.Point p = new Line.Point();
C.The Point class cannot be instatiated at line 15.
D.Line l = new Line() ; l.Point p = new l.Point();
第9题:
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?()
第10题:
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?()