42Exc
Exc
42
编译失败
第1题:
现有: class Tree { private static String tree = "tree "; String getTree () { return tree; } } class Elm extends Tree { private static String tree = "elm "; public static void main (String [] args) { new Elm() .go (new Tree()) ; } } void go (Tree t) { String s = t.getTree () +Elm.tree + tree + (new Elm() .getTree ()) ; System.out.println (s) ;} 结果为:()
第2题:
class Mineral { static String shiny() { return "1"; } } class Granite extends Mineral { public static void main(String [] args) { String s = shiny() + getShiny(); s = s + super.shiny(); System.out.println(s); } static String getShiny() { return shiny(); } } 结果为:()
第3题:
Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()
第4题:
现有: class Top { static int x=l; public Top (inty) { x*=3; } } class Middle extends Top { public Middle() {x+=1; ) public static void main (String [] args) { Middle m = new Middle(); System. out .println (x); } } 结果为:()
第5题:
定义类: package utils; public class Rep{ public static String twice (String s){return s+s ;} } 再定义另一个类Demo: //insert code here public class Demo{ public static void main (String[] args){ System. out .println( twice( "Hello")); } } 在第一行插入哪项代码,可以使程序正常编译和执行?()
第6题:
2
3
4
编译失败
第7题:
42
编译失败。
无输出结果。
运行时异常被抛出。
第8题:
42
编译失败
无输出结果
运行时异常被抛出
第9题:
import utils.*;
import utils.Rep.*;
import static utils.Rep.twice;
static import utils.Rep.twice;
第10题:
TeStA
TeStB
编译失败
运行时抛出异常
第11题:
import utils.*;
static import utils.*;
importutils.Repetition.*;
static importutils.Repetition.*;
import utils.Repetition.twice();
import static utils.Repetition.twice;
static import utils.Repetition.twice;
第12题:
42
编译失败。
无输出结果。
运行时异常被抛出。
第13题:
Which declarations will allow a class to be started as a standalone program?()
第14题:
class TestA { public void start() { System.out.println(”TestA”); } } public class TestB extends TestA { public void start() { System.out.println(”TestB”); } public static void main(String[] args) { ((TestA)new TestB()).start(); } } What is the result?()
第15题:
现有: class Parser extends Utilis { public static void main (String [] args) { try { System. out.print (new Parser ( ) .getlnt ("42")} ; } catch (NumberFormatException n) { System.out .println ( "NFExc" ) ; } } int getlnt (String arg) throws NumberFormatException{ return Integer.parselnt (arg) ; } class Utils { int getlnt (String arg) { return 42; } } 结果为 :()
第16题:
现有: class TestA { public void start() { System.out.println("TestA"); } } public class TestB extends TestA { public void start() { System.out.println("TestB"); } public static void main (string[] args) ( ((TestA)new TestB()).start(); ) } 运行结果是哪项?()
第17题:
class Parser extends Utils { public static void main(String [] args) { System.out.print(new Parser().getInt("42")); } int getInt(String arg) { return Integer.parseInt(arg); } } class Utils { int getInt(String arg) throws Exception { return 42; } } 结果为:()
第18题:
NFExc
42
42NFExc
编译失败
第19题:
elm elm elm elm
tree elm elm elm
tree elm elm tree
tree elm tree elm
第20题:
chirp chirp
chirp hello
hello hello
编译失败
第21题:
1
2
3
编译失败
第22题:
TestA
TestB
Compilation fails.
An exception is thrown at runtime.
第23题:
import utils.*;
static import utils.*;
import utils.Repetition.*;
static import utils.Repetition. *;
import utils.Repetition.twice();
import static utils.Repetition.twice;
static import utils.Repetition.twice;
第24题:
3
12
111
编译失败