//point X public class foo { public static void main (String[]args) throws Exception { java.io.printWriter out = new java.io.PrintWriter { new java.io.outputStreamWriter (System.out), true; out.printIn(“Hello”); } } } Which statement at PointX on line 1 allows this code to compile and run?() A、 Import java.io.*;B、 Include java.io.*;C、 Import java.io.PrintWriter;D、 Include java.io.PrintWriter;E、 No statement is needed.
//point X public class foo { public static void main (String[]args) throws Exception { java.io.printWriter out = new java.io.PrintWriter { new java.io.outputStreamWriter (System.out), true; out.printIn(“Hello”); } } } Which statement at PointX on line 1 allows this code to compile and run?()
- A、 Import java.io.*;
- B、 Include java.io.*;
- C、 Import java.io.PrintWriter;
- D、 Include java.io.PrintWriter;
- E、 No statement is needed.
相关考题:
有如下类定义:class Point{int x_, y_;public:Point():x_(0), y_(0){}Point(int x, int y = 0):x_(x),y_(y){}};若执行语句Point a(2), b[3] , *c[4];则 Point 类的构造函数被调用的次数是A . 2 次B . 3 次C . 4 次D . 5 次
( 33 )下面程序中对一维坐标点类 Point 进行运算符重载#includeusing namespace std;class point {public:point ( int vaI ) {x=val;}point & operator++ () {x++;retum*this;}print operator++ ( int ) {point ld=*this,++ ( *this ) ;retum old;}int GetX () const {retum x;}private:int x;};int main (){point a ( 10 ) ;cout ( ++a ) .GetX () ;coutA++.GETX () ;retum () ;}编译和运行情况是A )运行时输出 1011B )运行时输出 1111C )运行时输出 1112D )编译有错
下面程序中对一维坐标点类Point进行运算符重载 include using namespace std; 下面程序中对一维坐标点类Point进行运算符重载 #include <iostream> using namespace std; class Point { public: Point(int val) {x=val;} Point operator++() {x++; return *this; } Point operator++(int) {Point ld = *this; ++(*this); return old;} int GetX() const {return x;} private: int x; }; int main() { Point a(10); cout << (++a).GetX(); cout << a++.GetX(); return 0; }编译和运行情况是A.运行时输出1011B.运行时输出1111C.运行时输出1112D.编译有错
下面程序的输出结果是【】。include include class point{double x; double y; 下面程序的输出结果是【 】。include <iostream.h>include <math.h>class point{double x;double y;public:point(double a, double b){x=a;y=b;}friend double distance(point a, point b) ;};double distance(point a, point b){return sqrt ((a. x-b.x) * (a. x-b.x)+ (a. y-b. y) * (a. y-b. y) );}void main(){point p1(1,2);point p2(5,2);cout<<distance(p1,p2)<<end1;}
阅读下列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();}
下面程序的输出结果是【】。 inclde include using namespace std; class point { 下面程序的输出结果是【 】。inclde<iostreamn>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);};double distance(point a,point b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int main(){point p1(1,2);point p2(5,2);cout<<distalice(p1,p2)<<endl;return 0;}
有如下类定义: class Point { int xx.yy; public: Point:xx(0),yy(0){} Point(int x,int Y=0):xx(X),YY(Y){} }; 若执行语句 Point a(2),b[3],幸c[4]; 则Point类的构造函数被调用的次数是( )。A.2次B.3次C.4次D.5次
有如下程序: 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.
有以下程序: include using namespace std; class Point' { public: void SetPoint( 有以下程序: #include <iostream> using namespace std; class Point' { public: void SetPoint(int x,int y); void Move(int xOff,int yOff); int GetX() { return X; } int GetY() { return Y; } private: int X,Y; }; void Point::SetPoint(int x, int y) { X=x; Y=y; } void Point: :Move(int xOff, int yOff) X+=xOff; Y+=yOff; } int main () { Point p1; p1.SetPoint(1,2); p1.Move (5, 6); cout<<"Point1 is ("<<p1.GetX()<<','<<p1.GetY()<<")"<<end1; return 0; } 执行后的输出结果是( )。A.Point1 is (6,8)B.Point1 is (1,2)C.Point1 is (5,6)D.Point1 is (4,4)
有如下程序:#includeiostream#includecmathusing std::cout;class Point{public:friend double distance(const Point p); //P距原点的距离Point(int xx=0,int yy=0):x(xx),Y(YY){}//①private:int x,y;};double distance(const Point p){ //②return sqrt(P.x*P.x+P.y*P.y);}int main(){Point p1(3,4);coutdistance(p1);return 0; //③}下列叙述中正确的是A.程序编译正确B.程序编译时语句①出错C.程序编译时语句②出错D.程序编译时语句③出错
下面程序的输出结果是()。includeincludeusing namespace std;class point{p 下面程序的输出结果是( )。 #include<iostream> #include<math.h> using namespace std; class point { private: double x; double y; public: point(double a,double b) { x=a; y=b; } friend double distances(point a,point b); }; double distances(point a,point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } int main() { point p1(1,2); point p2(5,2); cout<<distances(p1,p2)<<end1; return 0; }A.2B.4C.8D.16
有如下程序:include using namespace std;class point{int x, y;public:point( int v 有如下程序:#include <iostream>using namespace std;class point{ int x, y;public: point( int vx, int vy ) { X=vx; y=vy; } point() { x=0; y=0; } point operator+ ( point p1 ) { point p; int px = x + p1.x; int py = y+ p1.y; return point( px, py ); } point operator-( point p1 { point p; int px = x - p1.x; int py = y - p1.y; return point( px, py ); } void print() { cout<<x<<","<<y<<end1; }};int main(){ point p1( 10, 10 ), p2( 20, 20 ); p1 = p1 + p2; p1.print(); return ();}执行后的输出结果是( )。A.10, 10B.20, 20C.10, 20D.30, 30
有以下程序: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
有以下程序: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 Point{int x__, y__;public:Point(): x_(0), y_(0) {}Point(int x, int y =0): x_(x), y_(y) {}若执行语句Point a(2),b[3], *c[4];则Point 类的构造函数被调用的次数是( )。A.2次B.3次C.4次D.5次
有以下程序:include include using namespace std;class point{private:doubl 有以下程序:#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 ; };double distance(point a, point b return sqrt((a. x-b. x )*(a. x -b. x )+ (a. x -b. x)*(a. x-b. x));}int main (){ point p1 (1,2); point p2(5,2); cout<<distance (p1, p2)<<end1; return 0;} 程序运行后的输出结果是A.1B.5C.4D.6
有如下程序:include using namespace std;class point{intx,y;public:point( int vx, 有如下程序:#include <iostream>using namespace std;class point{ int x, y;public: point( int vx, int vy ) { x = vx; y = vy; } point ( ) x = 0; y= 0; } point operator+( point p1 ) { point p; int px = x+ p1.x; int py = y + p1.y; return point( px, py ); point operator-( point p1 ) { point p; int px = x -p1.x; int py = y - p1.y; return point ( px, py ); } void print() { cout<<x<<" , "<<y<<end1; }};int main (){ point p1(10, 10 ), p2( 20, 20 ); p1 = p1 - p2; p1.print (); return 0;} 执行后的输出结果是A.10,10B.20,20C.10,20D.30,30
请教:2016年计算机二级C++基础练习二简答题2如何解答? 有以下两个程序,分析它们的执行结果有什么不同。程序1:#includeclass Point{int x,y;public:Point(){x=y=0;}Point(int i,int j){x=i;y=j;}Point operator+(Point);void disp() ( cout”(”}Point Point::operator+(Point P){this-x+=P.x; this-y+=p.y;return *this;}void main(){Point pl(2,3),p2(3,4),p3;cout”p1:”;p1.disp();cout”p2:”;p2.disp();p3=pl+p2;cout”执行p3=p1+p2后”cout”p1:”,p1.disp();cout”p2:”;p2.disp();cout”p3:”;p3.disp();}程序2:#includeclass Point{int x,Y;public:Point(){x=y=O;}Point(int i,int j){x=i,y=j;}Point operator+(Point);void disp f){cout ”(”}Point Point::operator+(Point P){Point s;s.x=x+p.x; s.y=y+p.y;return s;}void main(){Point pl(2,3),p2(3,4),p3;cout”p1:”;p1.disp();cout”p2:”;p2.disp();p3=pl+p2;cout”执行p3=p1+p2后”cout”p1:”;p1.disp();cout”p2:”;p2.disp();cout”p3:”;p3.disp();}
有如下程序: 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 vx, int vy ) { x = vx; y = vy; } point ( ) { x = 0; y = 0; } point operator+( point pl ) { point p; int px = x + p1.x; int py = y + p1.y; return point( px, py ); } point operator-( point p1 ) { point p; int px = x - p1.x; int py = y - p1.y; return point( px, py ); } void print() { cout<<x<<", "<<y<<end1; } }; int main () { point pl ( 10, 10 ), p2 ( 20, 20 ); p1 = p1 + p2; p1.print (); return 0; } 执行后的输出结果是( )。A.10,10B.20,20C.10,20D.30,30
有以下程序: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
有以下类定义: class Point { public: Point(int x=0,int y=0){_x=x; _y=y;} void Move(int x Off, int y Off) {_x+=x Off; _y+=y Off; } void Print() const { cout <<'(' << _x << ',' << _y << ')'<< end 1;} private: int _x,_y; }下列语句中会发生编译错误的是______。A.Point pt; pr. Print();B.const Point pt; pt. Print();C.Point pt; pt. Move(1,2);D.const Point pt; pt. Move(1,2);
若有以下程序: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{ public: Point{int x = 0, int y=0) {_x = x; _y = y;} void Move int xoff, int yoff) {_x +=xoff;_y+=yoff;} void Print() const {cout<<'('<<_x<<','<<_y<<')' << end1;} private: int_x,_y; }; 下列语句中会发生编译错误的是A.Point pt;pt.Print();B.const Point pt;pt.Print();C.Point pt;pt.Move(1, 2);D.const Point pt;pt.Move(1, 2)
有以下程序:includeincludeusingnamespacestd;classDistance;classpoint{pub 有以下程序: #include <iostream> #include <cmath> using namespace std; class Distance; class point { public: friend class Distance; Point(int a,int B) { x=a; Y=b; } void Print() { cout<<"X= "<<X<<end1; cout<<"Y= "<<Y<<end1; } private: float X,Y; }; class Distance { public: float Dis(Point p,Point q); }; float Distance :: Dis(Point p,Point q) { float result; result=sqrt((p.X-q.X)*(p.X-q.X)+(p.Y-q.Y)*(p.Y-q.Y)); cout<<result<<end1; retUrn result; } int main() { Point p(10,10),q(10,30); Distance d; d.Dis(p,q); return 0; } 运行后的输出结果是( )。A.10B.30C.0D.20
试完成下述程序片段: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
关于S1/X2接口数据配置,以下说法错误的是()。A、end-point方式用户要配置S1/X2链路的SCTPandIPPathB、end-point方式中,系统根据MMEIP自动填写IPPATHPeerIPC、end-point方式中,系统根据SGWIP自动填写SCTPLNKPeerIPD、推荐配置方式为end-point方式
有以下说明语句:struct point{int x;int y;}p;则正确的赋值语句是()A、point.x=1;point.y=2;B、point={1,2};C、p.x=1;p.y=2;D、p={1,2};