网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
若有说明class Y{//…;public:staticint n;};int Y::n;Y objY;,则对n的正确访问语句是()
A
n=1;
B
Y::n=1;
C
objY::n=1;
D
Y->n;
参考答案
参考解析
解析:
暂无解析
更多 “单选题若有说明class Y{//…;public:staticint n;};int Y::n;Y objY;,则对n的正确访问语句是()A n=1;B Y::n=1;C objY::n=1;D Y-n;” 相关考题
考题
阅读下面程序: include void fun(int n) { int x(5); static int y(10); if(n>0) {
阅读下面程序:include<iostream.h>void fun(int n){int x(5);static int y(10);if(n>0){++x;++y;cout<<x<<","<<y<<end1;}}void main(){int m(1);fun(m);}则该程序的输出结果是______。
考题
阅读下面程序: include void f(int n) { int x(5); static int y(10); if(n>0) { ++
阅读下面程序:include<iostream.h>void f(int n){int x(5);static int y(10);if(n>0){++x;++y;cout<<x<<","<<y<<endl;}}void main(){int m(1);f(m),}则该程序的输出结果是【 】
考题
( 31 )有如下类定义:class XX{int xx;public:XX ( ) : xx ( 0 ) {cout' A';}XX ( int n ) : xx ( n ) {tout' B';}};Class YY:public XX{Int yy;public:YY ( ) : yy ( 0 ) {cout+yy;}YY ( int n ) : XX ( n+1 ) , yy ( n ) {coutyy;}YY ( int m, int n ) : XX ( m ) , yy ( n ) {coutyy;}};下列选项中,输出结果为 A0 的语句是A ) YY y1(0,0);B ) YY y2(1);C ) YY y3(0);D ) YY y4;
考题
执行下列程序段之后,变量n的值为( )。 public class Test { public static void main(String[ ] args){ int y = 2; int z = 3; int n = 4; n=n+-y* z/n; System.out.println(n); } }A.3B.-1C.-12D.-3
考题
有如下程序:includeusing namespace std;class Base{int x;public:Base(int n=0):x(n
有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;} int getX( )const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int n):y(m),Base(n){tout<<m;} Derived(int m):y(m){cout<<m;} }; int main( ){ Derived dl(3),d2(5,7); return 0; } 程序的输出结果是A.375B.357C.0375D.0357
考题
有如下类声明: class XA{ int X; public: XA(int n){x=n;} }; class XB:public XA{ int y; public: XB(int a,int b); }; 在构造函数XB的下列定义中,正确的是( )。A.XB::XB(inta,int b):x(a),y(b){}B.XB::XB(int a,int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b){}D.XB::XB(int a,int b):XA(a),XB(b){}
考题
有如下类声明: class XA{ int X; public: XA(int n){x=n;} }; class XB:publicXA{ int y; public: XB(int a,int b); ); 在构造函数XB的下列定义中,正确的是( )。A.XB::XB(int a,int b):x(a),y(b){}B.XB::XB(int a,int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b){}D.XB::XB(int a,int b):XA(a),XB(b){}
考题
本题中,鼠标在窗口中单击一下,就在单击的位置生成一个小矩形,如果在小矩形上双击鼠标左键,则删除小矩形。 import java.awt.*; import java.awt.event.*; import javax swing.*; class MousePanel extends JPanel extends MouseMo- tionListener {public MousePanel {addMouseListener(new MouseAdapter {public void mousePressed(MouseEvent evt) {int X=evt.getX; int Y=evt.getY; current=find(x,y); if(current0) add(x,y); } public void mouseClicked(MouseEvent evt) {int X=evt.getX; int Y=evt.getY; if(evt.getClickCount=2) {remove(current); } } }); addMouseMotionListener(this); } public void paintComponent(Graphics g) {super.paintComponent; for(int i=0;insquares;i++) draw(g,i); } public int find(int X,int y) (for(int i=0;insquares;i++) if(squares[i].x-SQUARELENGTH/2= x X=squares[i].x+SQuARELENGTH/2 squares[i].Y-SQUARELENGTH/2 =Y y=squares[i].Y+SQUARELENGTH /2) return i ; return-1 ; } public void draw(Graphics g,int i) {g.drawRect(squares[i].X-SQUARE- LENGTH/2。 squares[i].Y-SQUARELENGTH/2, SQUARELENGTH, SQUARELENGTH); } public void add(int X,int Y) {if(nsquaresMAXNSQUARES) {squares[nsquares]=new Point(x,y); current=nsquares ; nsquares++; repaint; } } public void remove(int n) {if(n0 ‖ n=nsquares)return; Nsquares- -; squares[n]=squares[nsquares]; if(current= =n)current= -l; repaint; } public void mouseMoved(MouseEvent evt) {} public void mouseDragged(MouseEvent evt) {} private static final int SQUARELENGTH=10: private static final int MAXNSQUARES=100; private Point[]squares=new Point[MAX- NSQUARES]; private int nsquares=0; private int current=-l; } class MouseFrame. extends JFramc {public MouseFrame {setTitle("java3"); setSize(300,200); addWindowListener(new WindowAdapter {public void windowClosing(WindowEvent e) {System.exit(0); } }); Container contentPane=getContentPane; contentPane.add(MousePanel); } } public class java3 {public static void main(String[]args) {JFrame. frame=new MouseFrame; frame.show; } }
考题
若有以下程序: include using namespace std; template T min(T x,T y) {i
若有以下程序:include <iostream>using namespace std;template <class T>T min(T x,T y){if(x<y)return x;elsereturn y;}int main(){int n1=2,n2=10;double d1=1.5;d2=5.6;cout<<min(n1,n2)<<",";cout<<min(d2,d2)<<end1;return 0;}程序运行后的输出结果是【 】。
考题
下列程序运行后的输出结果是( )。#include#includeusing namespace std;class Person{public:Person(string n):name(n) { coutprivate:int year,month,day;};class Student:public Person{public:Student(string n,int y,int m,int d,char c):birthday(y,m,d),sex(c),Person(n) { coutA. SB.PSC.DPSD.PDS
考题
有如下类声明: class XA { int x; public: XA(int n){x=n;} }; class XB:public XA { int y; public: XB(int a,int b); }; 在构造函数XB的下列定义中,正确的是A.XB::XB(int a,int b):x(a),y(b){}B.XB::XB(int a,int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b){}D.XB::XB(int a,int b):XA(a),XB(b){}
考题
有如下类声明:class XA{int x;public:XA(int U)}x=n;}};class XB:public XA{int y;public:XB(int a,int B) ;};在构造函数XB的下列定义中,正确的是A.XB::XB(int a,int B) :x(A) ,y(B) {}B.XB::xB(int a,int B) :XA(A) ,y(B) {}C.XB::XB(int a,int B) :x(A) ,XB(B) {}D.XB::XB(int a,int B) :XA(A) ,XB(B) {}
考题
有如下类说明: class TestClass{ int x; public: TestClass(int n){x=n;} }; class TestClass1:public TestClass{ int y; public: TestClass1(int a,int b); }; 在构造函数TestClass1的下列定义中,正确的是( )。A.TestClass1::TestClass1 (int a,int b):x(a),y(b){}B.TestClass1::TestClass1 (int a,int b):TestClass(a),y(b){}C.TestClass1::TestClass1 (int a,int b):x(a),TestClass1(b){}D.TestClass1::TestClass1 (int a,int b):TestClass(a),TestClass1(b){}
考题
执行下列程序段这后,变量n的值为______。 public class Test8 { public static void main(String[] args} { int y=2; int z=3; int n=4; n=n+-y*z/n; System.out.println (n); } }A.3B.-1C.-3D.-12
考题
执行下列程序段之后,变量n的值为( )。 public class Test { public static void main(String[ ] args){ int y = 2; int z = 3; int n = 4; n=n+-y* z/n; System. out. println(n); } }A.3B.-1C.-12D.-3
考题
有如下类定义:class XX{int XX;public:xx():xx(0){toutA;}XX(int n):xx(n){coutB;}};class Y:Y:public XX{int YY;public:YY():YV(O){coutYY;)YY(int n):xx(n+1),YY(n){coutYY;}YY(int m,int n):XX(m),YY(n){coutyy;)};下列选项中,输出结果为A0的语句是A.YY yl(0,0);B.YY 72(1);C.YY y3(0);D.YY y4;
考题
有如下程序: include using namespace std; class Base{ int x; pu
有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;) int getX()const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int n):y(m,)Base(n){cout<<m;} Derived(int m):y(m){cout<<m;} }; int main(){ Derived d1(3),d2(5,7) return 0; }运行时的输出结果是A.375B.357C.375D.357
考题
若有如下程序; #define X 3 #define Y X+1 #define Z Y*Y/2 main() { int n; for(n=1;n<=Z;n++) printf("%d",n); } 则程序运行后的输出结果是( )A.12345B.1234567C.12345678D.123456
考题
有如下类声明: class XA { int x; public: XA(int n) {x=n;} }; class XB: public XA{ int y; public: XB(int a,int b); };在构造函数XB的下列定义中,正确的是______。A.XB:: XB(int a, int b):x(a),y(b) { }B.XB::XB(int a, int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b)i}D.XB::XB(int a,int b):XA(a),XB(b){}
考题
若有如下程序: sub(int x) {int y=0; static int z=1; y+=x+2;z+=y+x; return(z); } main() {int t=1,n; for(n=0;n<3;n++)printf("%d,",sub(t)); } 则程序运行后的输出结果是 ( )A.5,5,5B.5,9,13,C.5,7,9,D.5,8,11,
考题
有如下程序: #includeiostream using namespace std; class Base{ int x: public: Base(int n=0):x(n){coutn;} int getXconst{return x;} }; cjass Derived:public Base{ int Y:. J;;Iublic: Derived(int m,int n):y(m),Base(n){coutm;} Derived(int m):Y(m){coutm;} }; int main { Derived dl(3),d2(5,7); retum 0; } 执行这个程序的输出结果是( )。A.375B.357C.0375D.0557
考题
若有以下程序: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
考题
下列程序段的执行结果为()。includeusing namespace std;class example{int n;public:
下列程序段的执行结果为( )。 #include<iostream> using namespace std; class example{ int n; public: example(int i){n=i;} void add(){s+=n;} static int s; void pr(){ cout<<s<<endl; } }; int example::s=0; int fuc(char *x); int main(){ example x(2),y(3),z(4); x. add(); y. add(); z.pr(); return 0; }A.2B.3C.5D.6
考题
若有说明class Y{//…;public:staticint n;};int Y::n;Y objY;,则对n的正确访问语句是()A、n=1;B、Y::n=1;C、objY::n=1;D、Y-n;
考题
public class Yikes { public static void go(Long n) {System.out.println(”Long “);} public static void go(Short n) {System.out.println(”Short “);} public static void go(int n) {System.out.println(”int “);} public static void main(String [] args) { short y= 6; long z= 7; go(y); go(z); } } What is the result?() A、 int LongB、 Short LongC、 Compilation fails.D、 An exception is thrown at runtime.
考题
public class Wow { public static void go(short n) {System.out.println(”short”); } public static void go(Short n) {System.out.println(”SHORT”);} public static void go(Long n) {System.out.println(” LONG”); } public static void main(String [] args) { Short y= 6; int z=7; go(y); go(z); } } What is the result?() A、 short LONGB、 SHORT LONGC、 Compilation fails.D、 An exception is thrown at runtime.
考题
单选题public class Yikes { public static void go(Long n) {System.out.println(”Long “);} public static void go(Short n) {System.out.println(”Short “);} public static void go(int n) {System.out.println(”int “);} public static void main(String [] args) { short y= 6; long z= 7; go(y); go(z); } } What is the result?()A
int LongB
Short LongC
Compilation fails.D
An exception is thrown at runtime.
热门标签
最新试卷