首页 > 大学本科
题目内容 (请给出正确答案)
[主观题]

请先阅读下面的代码D public class Test { public Test(){ System.out.println(构造方法一被调用了); } public Test(int x){ this(); System.out.println(构造方法二被调用了); } public Test(boolean b){ thi..

请先阅读下面的代码D public class Test { public Test(){ System.out.println("构造方法一被调用了"); } public Test(int x){ this(); System.out.println("构造方法二被调用了"); } public Test(boolean b){ this(1); System.out.println("构造方法三被调用了"); } public static void main(String[] args) { Test test = new Test(true); } } 上面程序的运行结果为下列哪一项?

A、构造方法一被调用了

B、构造方法二被调用了

C、构造方法三被调用了

D、以上三个选项之和

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“请先阅读下面的代码D public class Test {…”相关的问题
第1题
阅读下面的程序,程序执行后,运行结果为()public class test {public static void main(String args[]) {int i; float f =2.3f; double d =2.7;i = ((int)Math.ceil(f)) * ((int)Math.round(d))System.out.println(i) }}

A.9

B.5

C.6

D.6.1

点击查看答案
第2题
下面的Java源文件代码片断正确的是______。 A.package testpackage; public class Test{//do something…}

下面的Java源文件代码片断正确的是______。

A.package testpackage;

public class Test{//do something…}

B.import java.io.*;

package testpackage;

public class Test{//do something…}

C.import java.io.*;

class Person{//do something…)

public class Test{//do something…}

D.importjava.io.*;

importjava.awt.*;

public class Test{//do something…}

点击查看答案
第3题
给出下面的代码: public class Person{ int arr[]=new int[10]; public Static void main(String a[]){

给出下面的代码:

public class Person{

int arr[]=new int[10];

public Static void main(String a[]){

System.out.println(arr[1]);

以下叙述对的是______。

A.编译时出错 B.编译时正确而运行时出错

C.输出0 D.输出null

点击查看答案
第4题
给出下面的代码: class Person{ String name,department ; public void printValue(){ System.out.prin

给出下面的代码:

class Person{

String name,department ;

public void printValue(){

System.out.println("name is"+name);

System.out.println("department is "+department);

}

}

public class Teacher extends Person{

int salary;

public void printValue(){

//doing the same as in the parent method printValue()

//including print the value of name and department.

System.out.printin("salary is"+salary);

}

}

下面的______表达式可以加入printValue()方法的”doing the same as…”部分.

A.printValue(); B.this.printValue();

C.person.printValue();D.super.printValue();

点击查看答案
第5题
给出下面的代码: 1)public Void modify() { 2)int i, j, k; 3)i=100; 4)while (i>0 ) { 5)j=i*2; 6)

给出下面的代码:

1)public Void modify() {

2)int i, j, k;

3)i=100;

4)while ( i>0 ) {

5)j=i*2;

6)System.out.println ("The value of j is"+j );

7)k=k+ 1;

8)i--;

9)}

10)}

第______行在编译时可能产生错误。

A.4 B.6

C.7 D.8

点击查看答案
第6题
请阅读代码: import java.awt.*; public class E11-4 { public static void m
ain(String args[]) { Frame. f=new Frame("BorderLayout"); f.add("North",new Button("North")); f.add("East",new Button("East"}); f.add("West",new Button ("West")); f.add ("South", tf); f.setSize(200,200); f.pack (); f.setVisible (true); } 请将程序画线处填入正确的语句【 】,使得程序能够正确运行。

点击查看答案
第7题
阅读下面代码: import java.awt.*; public class Examll_2 { public static v
oid main(String args[]) { ______; f.add("North",new Button("North")); f.add("South",new Button("South")); f.add("East",new Button ("East")) ;; f.add("West",new Button("West")); f.add("Center",new Button ("Center")); f.pack (); f.setVisible(true); } } 请在程序中的画线处添上适当的语句【 】,使程序能正确执行。

点击查看答案
第8题
阅读下面代码: import java.awt.*; public class Exam11_2 { public static
void main (String args[]) { ______; f.add("North",new Button("North")); f.add("South",new Button("South")); f.add("East",new Button("East"));; f.add("West",new Button("West")); f.add("Center",new Button("Center")); f.pack(); f.setVisible(true); } } 请在程序中的画线处添上适当的语句【 】,使程序能正确执行。

点击查看答案
第9题
阅读下面代码: import java.awt.*; public class Exam11_1 { private Frame.
f; private Button bl,b2,b3,b4; public static void main(String args[] { Exam11_1 that = new Exam11_1 (); that.go(); } public void go () { ______; f.setLayout(new FlowLayout());; bl = new Button ("Button 1"); b2 = new Button ("Button 2"); b3 = new Button ("Button 3"); b4 = new Button ("Button 4"); f.add(b1); f.add(b2); f.add(b3); f.add(b4); f.pack(); f.setVisible(true); } } 请在程序中画线处填写正确的语句【 】,以便编译运行程序后得到正确的结果。

点击查看答案
第10题
有如下代码片段,请在画线处填入正确的代码,使程序运行正确。 import javax.swing.*; im
port java.awt.*; import java.event.*; public class JAppletTest extends【 】{ public void init() { Container contentPane = getContentPane(); Icon icon = new ImageIcon("swing.gif", "A GIF on a swing"); JLabel label = new JLabel("Swing!", icon, SwingConstants.CENTER); contentPane.add(label, BorderLayout.CENTER); } }

点击查看答案
退出 登录/注册
发送账号至手机
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改