有如下程序段: public class Parent { public int addValue (int a,intB){ int s; s=a+b; return 3; } } class Child extends Parent {} 则下列选项中,可以正确加入类Child中且父类的方法不会被覆盖的是( )。
A.int addValue (int a,intB){//do something...}
B.public void addValue() {//do something...}
C.public int addValue (int a,intB)throws MyException {//do something...}
D.public float addValue (int a,int b,float b=1.0) {//do someting...}
第1题:
有如下程序:
include <iostream>
using namespace std;
class PARENT
{
public:
PARENT() { cout <<"PARENT"; }
};
class SON : public PARENT
{
public:
SON() {cout << "SON"; }
};
int main()
{
SON son;
PARENT *p;
p = &son;
return 0;
}
执行上面程序的输出是______。
第2题:
有以下程序: #include <stdlib.h> void fun(int * s,int * * d) { * *d=*(s+2); } main() { int a[]={1,2,3,4,5},*b; b=(int *)malloc(sizeof(int)); fun(a,&B) ; printf("%d\n",*b+1); } 程序的输出结果是( )
A.2
B.3
C.4
D.5
第3题:
第4题:
若有如下程序: int s[3] [3]={'a','b','C','d','e','f','g','h','i'},*t; main() {t:(int*)malloc(sizeof(int)); sub(t,s); printf("%c\n",*t); } sub(int*p,int b[][3]) {*p=b[2][1]; } 则程序运行后的输出结果是( )。
A.d
B.e
C.h
D.b
第5题:
第6题:
对于下面代码,空白处正确的是 class S { public: auto x {3}; auto y {1.1}; auto z { 'a' }; } int main () { S s; ____________________; std::cout << a << "t" << b << "t" << c; return 0; }
A.auto [a, b, c] { s }
B.int a, b, c = s
C.int [ a, b, c ] = {s}
D.auto a {s}, b{s}, c{s}