中国大学MOOC: 已知关于抽象方法错误代码,正确修改是( ):class Base{ abstract void hello(){ System.out.println(hello); } }
举一反三
- 下面的代码中正确的是 A: class Example { abstract void g(); } B: interface Example { void g() { System.out.print("hello"); } } C: abstract class Example { abstract voidg() { System.out.print("hello"); } } D: abstract class Example { void g() { System.out.print("hello"); } }
- 中国大学MOOC: 下列代码中构造方法的返回类型是()public class Village { Village () { System .out .println(“hiding in Village”) ; } public static void main( String args [ ]) { Village c =new Village ( ) ;}class Village { public static void main( String args [ ]) { Village c =new Village ( ) ; } Village () { System .out .println(“hiding in Village”) ; } }
- (6-2)以下代码会出现编译错误。 class Base{ public Base () { System.out.println("1"); } public void Base () { System.out.println("2"); } }
- 下面C#程序正确的是()。 A: using System; <br/>class Hello <br/>{ <br/>static void<br/>Main()<br/>{<br/>Console.WriteLine("Hello, world"); <br/>} <br/>} B: using System; <br/>static void Main()<br/>{<br/>Console.WriteLine("Hello, world"); <br/>} C: using System; <br/>class Hello;<br/>static void<br/>Main();<br/>{<br/>Console.WriteLine("Hello, world");<br/>} <br/>} D: using System<br/>class Hello<br/>{ <br/>static void<br/>Main()<br/>{<br/>Console.WriteLine("Hello, world")<br/>} <br/>}
- 下列代码执行结果是?( ) class HelloWorld { public static void modifyString(final String str) { str = "Hello World!"; } public static void main(String[] args) { String a = new String("Hello Java"); modifyString(a); System.out.println(“a = ” + a); } } A: a = Hello Java B: a = Hello World C: 代码编译错误 D: 运行时异常