下面的程序中,哪行会报错? public class StaticTest { ....showTotalFee(); } }
line 2
举一反三
- 下面的程序中,哪行会报错? public class StaticTest { int age; String name; static int totalFee = 500; public void showName() { System.out.print(this.name); } public static void showTotalFee() { line 1: System.out.print(totalFee); line 2: showName(); } public static void main(String[] args) { line3: StaticTest.showTotalFee(); } }
- 下面程序的运行结果是public class Demo { public static void main(String[] args) { new Object(){ public void show(){ System.out.println("helloworld"); } }.show(); }} A: 什么也不输出 B: helloworld C: 编译报错 D: 编译通过,运行报错
- 下列的程序的运行结果是( )public class Example { public static void main(String[] args) { new Father () { public void show() { System.out.println("helloworld"); } }.show(); }}class Father { public void show() { System.out.println("hellofather"); }} A: hellofather B: helloworld C: 编译报错 D: 编译通过,运行报错
- 下面程序段中不正确的是( )。 A: package myPackage;public class A{} B: package myPackage; class B{ } C: package myPackage; import java.io.*; public class C{ } D: import java.awt.Color; package myPackage; class D{ }
- 下面的程序中,哪行会报错? publicclassStaticTest{ intage; Stringname; staticinttotalFee=500; publicvoidshowName(){ System.out.print(this.name); } publicstaticvoidshowTotalFee(){ line1:System.out.print(totalFee); line2:showName(); } publicstaticvoidmain(String[]args){ line3:StaticTest.showTotalFee(); } }
内容
- 0
读下面程序:public class TestException {publ...b);}}程序运行后产生的异常是?
- 1
【单选题】下列哪行代码有错误? public class Example{ public static void main(String args[]){ System.out.println("ok"); system.out.println("您好"); } } A. public class Example B. public static void main(String args[]) C. System.out.println("ok"); D. system.out.println("您好");
- 2
(4-1)写出下面程序运行结果。public class Demo5 {pu...[3]*arr.length);}}
- 3
下面程序段对应的输出结果是?public class Test5 {publ...em.out.print(m);}}
- 4
(2-6)请写出下面程序运行结果。public class Demo {pu....out.println(b);}}