第4行编译报错
第5行编译报错
编译成功,输出13
编译成功,输出14
第1题:
阅读下面代码 public class Person { static int arr[]=new int[10]; public static void main(String args) { System.out.println(arr[9]); } } 该代码的运行结果是
A.编译时将产生错误
B.编译时正确,运行时将产生错误
C.输出零
D.输出空
第2题:
下列代码的执行结果是( )。
public class Test{
public int aMethod( ){
static int i=0;
i++;
System.out.println(i):
}
public static void main (String args[]){
Trest test=new Test ( );
test aMethod( ):
}
}
A.编译错误
B.0
C.1
D.运行成功,但不输出
B.
C.
D.
第3题:
A. hello
B. hello2
C. 编译报错
D. 运行报错,不能将串与整数相加
第4题:
以下的程序的执行结果为? () public class Demo{ public double getHeight(){ return 171.0; } public int getHeight (){ return 171; } public static void main(String[] args){ Demo demo = new Demo(); System.out.println(demo.getHeight()); } }
第5题:
执行以下代码,输出结果的结果是? () public class Test{ public String[] ss = new String[5]; public static void main(String[] args){ System.out.println(ss[1]); } }
第6题:
执行以下代码后,下面哪些描述是正确的() public class Student{ private String name = “Jema”; public void setName(String name){ this.name = name; } public String getName(){ return this.name; } public static void main(String[] args){ Student s; System.out.println(s.getName()); } }
第7题:
下面程序的输出结果是() public class Test{ public static void main(String[] args){ String s = “abc dsf ghi”; String[] arr = s.split(“/s”); System.out.println(arr.length); } }
第8题:
编译如下Java程序片断: class test{ int count = 9; public void a(){ int count=10; System.out.println("count 1 =" + count); } public void count(){ System.out.println("count 2 =" + count); } public static void main(String args[]){ test t=new test(); t.a(); t.count(); } } 结果将()。
第9题:
不能通过编译
输出:count 1 =10 count 2=9
输出:count 1=9 count 2=9
第10题:
不能通过编译
输出: count 1 = 10 count 2 = 9
输出: count 1 = 9 count 2 = 9
第11题:
编译报错
LiLei hello
LiLeihello
无任何输出
第12题:
不能通过编译
通过编译,输出为:A B
通过编译,输出为:B
通过编译,输出为:A
第13题:
对于下面一段代码的描述中,正确的是______。 public class ex36 { public static void run main(String[] args) throws Excepion { method(); } static void method() throws Exception try { System.out.println("test"); } finally { System.out.println ("finally"); } } }
A.代码编译成功,输出“test”和“fmally”
B.代码编译成功,输出“test”
C.代码实现选项A中的功能,之后Java停止程序运行,抛出异常,但是不进行处理
D.代码不能编译
第14题:
类A及其派生类B定义如下:class A{ public int getInfo(int a) { return a; }}public class B extends A{ public float getInfo(int b) { return b; } public static void main(String[]args) { A a=new A(); B b=new B(); System.out.println(a.getInfo(3)+","+b.getInfo(5)); }}关于上述程序代码的叙述中正确的是 ( )
A.第10行不能通过编译
B.程序通过编译,输出结果为:3,3
C.程序通过编译,输出结果为3,5
D.程序通过编译,输出结果为:5,5
第15题:
以下程序调试结果为:
public class Test {
int m=5;
public void some(int x) {
m=x;
}
public static void main(String args []) {
new Demo().some(7);
}
}
class Demo extends Test {
int m=8;
public void some(int x) {
super.some(x);
System.out.println(m);
}
}
A.5
B.8
C.7
D.无任何输出
E.编译错误
第16题:
执行以下代码会输出什么结果?() public class Test { StringgetStr(String s){ return s + “hello”; } public static void main(String arg[]) { Test t= new Test(); System.out.println(t.getStr(“LiLei/n”)); } }
第17题:
执行下面程序,输出的结果是?() public class Test{ public static void main(String[] args){ int a = 5; double b = 8; a = a++ + b; System.out.println(a); } }
第18题:
给定如下Java程序片断: class A{ public A (){ System.out.println("A"); } } class B extends A{ public B(){ System.out.println("B"); } public static void main(String[] args){ B b=new B(); } } 上述程序将()。
第19题:
编译如下的Java程序片段: Class test{ Int count=9; Public void a(){ Int count=10; System.out,println(“count 1=” + count); } Public void count(){ System.out.println(“count 2 =”+ count); } Public static void main(String args[] ){ Test t=new Test(); t.a(); t.count(); } } 结果是()
第20题:
第4行编译报错
第5行编译报错
编译成功,输出13
编译成功,输出14
第21题:
输出null
第10行编译报错
第11行编译报错
输出Jema
第22题:
输出171.0
输出171
第2行和第5行编译报错
第10行编译报错
第23题:
编译报错
2
1
3
第24题:
null
-1
编译时出错
运行时报错