class ThreadExcept implements Runnable { public void run() { throw new RuntimeException("exception "); } public static void main(String [] args) { new Thread(new ThreadExcept()).start(); try { int x = Integer.parseInt(args[0]); Thread.sleep(x); System.out.print("main "); } catch (Exception e) { } } } 和命令行: java ThreadExcept 1000 哪一个是结果?()
第1题:
有以下程序 #include<iostream> using namespace std; class Complex { public: Complex(double r=O,double i=0):re(r),im(i){} double real() const {return re;} double imag()const {return im;} Complex operator +(Complex C) const {return Complex (re+c.re,im+c.im);} private: double re,im; }; int main() { Complex a=Complex(1,1)+Complex (5); cout<<a.real()<<'+'<<a.imag()<<'i'<<endl; retum 0; } 程序执行后的输出结果是
A.6+6i
B.6+1i
C.1+6i
D.1+1i
第2题:
有如下程序: #include <iostream> using namespace std; class Complex { double re, im, public: Complex(double r, double i): re(r), im(i) {} double real() const {return re;} double image() const {return im,} Complex& operator +=(Complex a) { re +=a.re; im +=a.im; return *this; } }; ostream& operator << (ostream& s, const Complex& z) { return s<<'('<<z.real()<<','<<z.image()<<')'; } int main() { Complex x(1,-2), y(2,3); cout << (x+=y) << endl; return 0; } 执行这个程序的输出结果是( )。
A.(1,-2)
B.(2,3)
C.(3,5)
D.(3,1)
第3题:
A、IM360
B、IM361
C、IM362
D、IM365
第4题:
有下列程序: #include<iostream> using namespace std; class Complex { double re,im; public: Complex(double r,double i):re(r),im(i){} double real()const{retum re;} double image()const{return im;} Complex& operator+=(Complex A) { r
A.(1,-2)
B.(2,3)
C.(3,5)
D.(3,1)
第5题:
若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(im i) { a=i; } void disp() cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp0 { cout<<b<<","; } }; class C: public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp0 { A::disp(); B::disp(); cout<<c<<endl; } }; int main() { C obj(10); obj.disp(); return 0; } 程序执行后的输出结果是( )。
A.10,10,10
B.10,12,14
C.8,10,12
D.8,12,10
第6题:
有以下程序 #include <iostream> using namespace std; class Complex { public: Complex (double r=0, double i =0 :re(r) ,im (i) {} double real() const {return re;} double imag() const { return im;} Complex operator + (Complex c} const {return Complex(re+c.re, im+c.im);} privane: double re,im; }; int main { Complex a =Complex (1,1)+Complex(5); cout<<a.real()<<'+'<<a.imag() << 'i' <<endl return 0; } 程序执行后的输出结果是
A.6+6i
B.6+1i
C.1+6i
D.1+1i
第7题:
有如下程序: #include<iostream> using namespace std; class Complex { double re,im; public: Complex(double r,double i):re(r),im(i){} double real()const{return re;} double image()const{return im;} Complex& operator+=(Complex a) { re+=a.re; im+=a.im; return *this; } }; ostream& operator<<(ostream& s,const Complex& z) { return s<<'('<<z.real()<<','<<z.image()<<')'; } int main() { Complex x(1,2),y(2,3); tout<<(x+=y)<<endl; return 0; } 执行这个程序的输出结果是( )。
A.(1,-2)
B.(2,3)
C.(3,5)
D.(3,1)
第8题:
有如下程序:
#include
using namespace std;
class Complex
{
double re, im;
public:
Complex(double r, double i):re(r), im(i){}
double real() const{return re;}
double image() const{return im;}
Complex& operator +=(Complex a)
{
re += a.re;
im += a.im;
return *this;
}
};
ostream &operator<<(ostream& s,const Complex& z)
{
return s<<'('<
}
int main()
{
Complex x(1, -2), y(2, 3);
cout<<(x += y)<
return 0;
}
执行这个程序的输出结果是
A . (1, -2)
B . (2, 3)
C . (3, 5)
D . (3, 1)
第9题:
下列程序在运行时会产生______。 import java.awt.*; public class ex33 { public static void maiN(String[] args) { Image im[] = new Image[4]; System.out.println (im[0] .toString ()); } }
A.NumberFormatExeeption
B.ArittnneticException
C.ArrayIndexOutOfBoundsExcepfion
D.NullPointerException
第10题:
有如下类定义: class AA { im a: public: int getRefconst{return&a;}//① int getValueconst{return a;}//② void set(int n)const{a=n;}//③ friend void show(AA aA.const{cout<<a;}//④ }; 其中四个函数的定义中正确的是( )。
A.①
B.②
C.③
D.④