首页/ 题库 / [单选题]下面程序段的输出结果是______。 p的答案

下面程序段的输出结果是______。 public class Test{ public static void main(String args[ ]){ int[ ]a=new int[11]; int[ ]p=new int[4]; int k=5; for(int i=1;i<=10;i++) a[i]=i; for(int i=1;i<=3;i++) p[i]=a[i*i]; for(int i=1;i<=3;i++) k=k+p[i]*2; System.out.println(k); } }

单选题
2022-02-28 20:07
A、37
B、31
C、33
D、35
查看答案

正确答案
C

试题解析
解析: 题中共定义了两个数组:a[ ]和p[ ],共用了3个for循环。第1个for循环语句对数组a[i]赋值;第2个for循环语句对数组P[i]赋值;第3个for循环语句计算k的值。正确答案为选项C。

标签:
感兴趣题目
下面程序段的输出结果是______。 public class Test{ public static void main(String args[ ]){ int[ ]a=new int[11]; int[ ]p=new int[4]; int k=5; for(int i=1;i<=10;i++) a[i]=i; for(int i=1;i<=3;i++) p[i]=a[i*i]; for(int i=1;i<=3;i++) k=k+p[i]*2; System.out.println(k); } }
编译和运行下列程序,请选择正确的输出结果______。 public class ex31 { private void test() { System.out.println(6 + 6 + "(Result)"); } public static void main(String[] args) { new ex31().test(); } }
以下程序段的输出结果是______。 int x=5; do {ptintf("%2d ",x--); }while(!x);
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是
阅读下面程序 public class Test implements Runnable{ public static void main(String[]args){ _______________________________________; t. start(); } public void mR(){ System. out. println("Hello!"); }} 在程序下画线处填入正确选项是
阅读下面Applet程序 import javax.swing.*: import java.awt.*: public Class Test SwingApplet extends JApplet { JLabel 1=new JLabel("This is a Swing Applet."); public void init() { ______ } } 程序中下画线处应填入的正确选项是
阅读下面Applet程序 import javax. swing. *; import java. awt. *; public class SwintgApplet extends JApplet{ JLabel 1=new JLabel("This is a Swing Applet."); public void init(){ ________________________________ } } 在程序下画线处填入正确的选项是
下面程序的执行结果是______。 public class ex27 { public static void main(String[] args) { try { return; } finally { System. out. print in ( "Finally" ); } }
在下列程序的划线处应填入的语句是 ( ) class Person { private int a; } public class Man extends Person { public int b public static void main(String arg[]) { Person P=new Person(); Man t=new Man(); int i; ______ } }
执行下列代码段之后,变量z的值为______。 Public class Test8 { public static void main(String[] args) { int x=2; int y=3; int z=4; z-....= y-x--; System.out.println(z); }
下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file " ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }
在下列程序的划线处应填入的语句是 class Pemon { pnvate int a; } public class Man extends Person { public int b; public static void main(String arg[ ] ) { Person p = new Person( ); Man t = new Man( ); int i; ________ } }
相关题目
下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file " ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }
应在下面程序下划线中填写的正确的语句是( )。 #include <iostream> using namespace std; class A{ public: void test(){cout<< "this is A!";} }; class B:public A{ void test(){ ______ //显示调用基类函数test() cout<< "this is B!"; } }; void main(){}
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是
阅读下面程序 public class Test implements Runnable{ public static void main(String[]args){ _______________________________________; t. start(); } public void mR(){ System. out. println("Hello!"); }} 在程序下画线处填入正确选项是
对于类定义 class A { public: virtual void funcl(){} void func2(){} }; class D:public A{ public: void funcl(){cout<< "class B rune 1"<<end1;} virtual void func2(){cout<< "class B func 2"<<end1;} }; 下面正确的叙述是 ______。
下列语句序列执行后,K的值是______。 public class Test11 { public static void main(String[] args) { int m=3, n=6, k=0; while ((m++)<(n--)) ++k; System.out.println (k); } }
下面程序段的输出结果是 ______。 int X=20, y=20; cout<<x- -<<" , "<< - -y;
下面程序的输出结果为______
若将“LOOP”改为“EXIT”,则程序段的输出结果为 ______。
阅读下面代码 public class Jixiangwu { public static void main(String[] args) { String[] stars={"贝贝","晶晶","欢欢","迎迎","妮妮"}; System.out.println("你抽取的奥运吉祥物是"+ "“"+stars[(int)(stars. ______ *Math.random())]+"”"+"!"); } } 为保证程序能正确执行,程序中下画线处应填写的是
下列程序段的执行结果是______。
执行如下语句之后,输出的结果是______。 public class ex36 { public static void main(String[] args) { int x=-6, y=6; x=x+y--; System.out.println (x); } }
执行如下语句之后,输出的结果是______。 public class ex24 { public static void main(String[] args) { int x=5,y=3; x+=X-- *--y; System.out.println{x); } }
下列程序段的输出结果是______。 public class Test{ int a,b; Test( ){ a=100; b=200; } Test(int x,int y){ a=X; b=y; } public static void main(String args[ ]){ Test Obj1=new Test(12,45); System.out.println("a="+Obj1.a+"b="+Obj1.B); Test Obj2=new Test( ); System.out.println("a="+Obj1.a+"b="+Obj1.B); } }
有如下类定义: class Test { int x_,y_; public: Test ():a_(0) ,b_(0) {} Test(int a,int b=0) :a_(a),b_(b){} }; 若执行语句 Test x(2) ,y[3],*z[4]; 则Test类的构造函数被调用的次数是( )。
执行下列代码之后,输出的结果为______。 public class ex27 { public static void main(String[] args) { iht x=7; int y=15; boolean bb=(127|x)>7&&(-128∧y)<15; System.out. println(bb); } }
下列程序的执行结果是______。 class A1 implements Runnable { public void run() { for(iht i = 0; i < 10; i++) { System.out.println("i =" + i); if(i == 3) break; } } } public class ex38 { public static void main(String[] args) { Thread th1 = new Thread(new A1()); th1.start (); } }
能将程序补充完整的选项是 class Person { private int a; public int change(int m){return m; } } public class Teacher extends Person { public int b; public static void main(String arg[]) { Person p=new Person(); Teacher t=new Teacher(); int i; ______ } }
能将程序补充完整的选项是______。 class Person{ private int a; phblic int change(int m){return m;} } public class Teacher extends Person{ public int b; public static void main(String arg[ ]){ Person p=new Person( ); Teacher t=new Teacher( ); int i; ______; } }
执行下列程序之后,变量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); } }
广告位招租WX:84302438

免费的网站请分享给朋友吧