以下程序的输出结果为。
abstractclassShape{
abstractvoiddisplay();
}
classCircleextendsShape{
voiddisplay(){
System.out.println("Circle");
}
}
classRectangleextendsShape{
voiddisplay(){
System.out.println("Rectangle");
}
}
classTriangleextendsShape{
voiddisplay(){
System.out.println("Triangle");
}
}
publicclassAbstractClassDemo{
publicstaticvoidmain(Stringargs[]){
(newCircle()).display();
(newRectangle()).display();
(newTriangle()).display();
}
}
abstractclassShape{
abstractvoiddisplay();
}
classCircleextendsShape{
voiddisplay(){
System.out.println("Circle");
}
}
classRectangleextendsShape{
voiddisplay(){
System.out.println("Rectangle");
}
}
classTriangleextendsShape{
voiddisplay(){
System.out.println("Triangle");
}
}
publicclassAbstractClassDemo{
publicstaticvoidmain(Stringargs[]){
(newCircle()).display();
(newRectangle()).display();
(newTriangle()).display();
}
}
举一反三
- 请看下面的程序代码,当 n 为( )值时,程序段将输出字符串 second。 [br][/br] switch(n) { [br][/br] case 0: System .out .println(“first”); [br][/br] case 1: [br][/br] case 2: System .out .println(“second”); break; [br][/br] default: System .out .println(“end”); [br][/br] }(2.0) A: 0 B: 1 C: 2 D: 以上都可以
- 中国大学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”) ; } }
- 以下程序段的输出结果为 【14】 。int x=0,y=4,z=5;if(x>2)if(y<5)System. out. println("Message one");elseSystem. out . println("Message two");else if(z>5)System. out. println("Message three");elseSystem. out. println("Message four");
- 要查看网络设备使用的操作系统版本等信息,可采用下列( )命令。 A: display version B: display current- configuration C: display system D: show system
- The keyboard, mouse, display, and system unit are: