下列程序的输出结果是 class Father{ int m.n; Father(int a,int B) { m=a; n=b } void

题目

下列程序的输出结果是

class Father{

int m.n;

Father(int a,int B)

{ m=a;

n=b

}

void show ( ){

System.out.println("m and n:"+m+" "+n);

}

}

class Son extends Father{

int p;

Son (int a,int b,int C)

{ super(a,B) ;

p=c;

}

void show(){supur.show( );

System.out.println("p:"+p);

}

}

class Test {

public static void main (String args[ ])

{ Son s:new Son(6,7,8);

s.show( );

}

}

A.m and n:6 8 p:7

B.m andn:6 7 p:8

C.m and n:7 8 p:6

D.m and n:8 7 p:6

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

以下程序的输出结果是______。include void swap(int *a, int *b){ int *t;}{ int i=3,j

以下程序的输出结果是______。

include <stdio.h>

void swap(int *a, int *b)

{ int *t;

}

{ int i=3,j=5,*p=&i,*q=&j;

swap(p,q); printf("%d %d\n",*p,*q);


正确答案:

第2题:

有以下程序include<stdio.h>int*f(int*p,int*q);main( ){int m=1,n=2,*r=&m;r=f(r,&am

有以下程序

include<stdio.h>

int*f(int*p,int*q);

main( )

{int m=1,n=2,*r=&m;

r=f(r,&n);printf(”%d\n”,*r);

}

int-f(int*P,int*q)

(return(*p>*q)?p:q;)

程序运行后的输出结果是______。


正确答案:2
2 解析:函数f的返回值的类型是int*,作用是返回两个int*型指针所指变量中值大的那个指针的。本题中定义了一个int*型指针r并置初值&m,即指针r指向m。r=f(r,&n),由于m的值小于n值,所以f函数返回值为&n,所以输出为2,即n值。

第3题:

下列程序的运行结果是()。include< iostream.h>void fun (int *a,int*b){int*kk=a;a=b;b=k}void

下列程序的运行结果是( )。 #include< iostream.h> void fun (int *a,int*b) {int*k k=a;a=b;b=k} void main() {int a=2004, b=9,*x=&a,*y=&b; fun(x, y) ; cout<<a<<" "<<b<<endl:}

A.20049

B.92004

C.0

D.编译时出错


正确答案:A

第4题:

00330038003000301585067361821下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

A.<class 'int'> <class 'float'> <class 'str'>

B.<class 'float'> <class 'int'> <class 'str'>

C.<class 'str'> <class 'float'> <class 'int'>

D.<class 'str'> <class 'int'> <class 'float'>


A

第5题:

有下列程序: #include<stdi0.h> voidf(int*P,int*q); voidmain( ) (intm=1,n=2,*r=&m; f(r,&n);printf("%d,%d",m,n); } voidf(int*P,int*q)

{p=p+1;*q=*q+1;} 程序运行后的输出结果是( )。

A.1,3

B.2,3

C.1,4

D.1,2


正确答案:A
A。【解析】本题中子函数f(int*p,*q)的功能是对指针p的值加1,*q的值加1。主函数中调用子函数f(r,&n)时,子函数的执行结果是r值加1,n的值加1。而m的值并没有发生变化,最后程序输出的结果为1,3。所以正确答案为选项A。

第6题:

有以下程序includevoid f(int *p,int *q);main(){ int m=1,n=2,*r=&m;f(r, &n

有以下程序 #include<stdio.h> void f(int *p,int *q); main() { int m=1,n=2,*r=&m; f(r, &n); printf("%d,%d",m,n); } void f(int*p,int*q) {p=p+1; *q=*q+1;) 程序运行后的输出结果是______。

A.1,3

B.2,3

C.1,4

D.1,2


正确答案:A
解析:本题主要考查函数实参和形参之间的传递,C语言规定,实参变量对形参变量的数据传递是“值传递”,即单向传递,只能由实参传绐形参,而不能由形参传回来给实参。f(r&n)把n的地址传递给q,通过地址传递的函数可以有返回值,因此,n的值为q的返回值3,又因为p是形参变量没有返回值,所以m的值没有改变,因此,选项A是正确的。

第7题:

以下程序的输出结果是#include "stdio.h"int *fun(int *a,int *b){ int m; m=*a; m+=*b-3; return(&m);}main(){ int x=21,y=35,*a=&x,*b=&y; int *k; k=fun(a,b); printf("%d\n",*k);}


正确答案:53
本题考查指针函数的使用。题目给出的程序包括两个部分,一个为指针函数fun,一个为主函数main。主函数main部分给出两个整型变量x和y,并给出相应的赋值。main函数的执行结果为输出*k的值,而*k的值即*fun的值。fun函数包括两个整型指针形参*a和*b。通过对*a、*b进行操作,得到结果m,并将m值返回,整个程序的实际输出即为m的值。初始时,m=*a=21。随后令m=m+*b-3,得m=53。整个程序的输出结果即为53。

第8题:

下列程序的输出结果是【 】。include void swap(int *a, int *B) { int *t; t=a;a=b;b=t;

下列程序的输出结果是【 】。

include <stdio.h>

void swap(int *a, int *B)

{

int *t;

t=a;a=b;b=t;

}

main()

{

int i=3,j=5,*p=&i,*q=&j;

swap(p,q);printf("%d %d\n",*p,*q);

}


正确答案:3 5
3 5 解析:本题考查函数中实参和形参的传递,在C语言函数中实参和形参传递具有不可逆性,参数只能由实参传向形参,而不能由形参传向实参,虽然swap函数的功能是实现两个数的交换,但没有返回值,故最终的输出结果为3 5。

第9题:

以下程序的输出结果是( )。 include void swap(int*a,int*B){int*t; t=a;a=b;b=c;} main

以下程序的输出结果是( )。 include<stdio.h> void swap(int*a,int*B){int*t; t=a;a=b;b=c;} main() {int i=3,j=5,*p=&i,*q=&j; swap(p,q);printf("%d %d\n",*p,*q); }


正确答案:3 5
3 5 解析:本题考查函数中形参和实参的传递。在C语言函数中实参和形参传递具有不可逆性,参数只能由实参传向形参,而不能由形参传向实参,虽然swap函数的功能是实现两个数的交换,但由于没有返回值,故最终的输出结果为3 5。

第10题:

下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

A.<class 'int'> <class 'float'> <class 'str'>

B.<class 'float'> <class 'int'> <class 'str'>

C.<class 'str'> <class 'float'> <class 'int'>

D.<class 'str'> <class 'int'> <class 'float'>


C.循环执行1次