下列定义类的格式,和创建对象格式正确的是()
A: public class Cell{ private int row; int col; public void getCellInfo(){System.out.println(row+":"+col); }}
B: 创建对象的格式:Cell c=new Cell();
C: public class Cell(){ private int row; int col; public void getCellInfo(){System.out.println(row+":"+col); }}
D: 创建对象的格式:Cell c=new Cell;
A: public class Cell{ private int row; int col; public void getCellInfo(){System.out.println(row+":"+col); }}
B: 创建对象的格式:Cell c=new Cell();
C: public class Cell(){ private int row; int col; public void getCellInfo(){System.out.println(row+":"+col); }}
D: 创建对象的格式:Cell c=new Cell;
举一反三
- 选择填空,创建一个包含两行两列的表格。 row 1, cell 1: <>row 1, cell 2 <> row 2, cell 1 row 2, cell 2
- 下面哪个程序变量age的定义是正确的() A: public class Employee{ public void show(){ System.out.println(age); } public int age; } B: public class Employee{ public void show(){ System.out.println(age); int age = 20; } } C: public class Employee{ public void show(){ System.out.println(age); } }
- 有如下类的定义,创建Employee对象正确的是() public class Employee{ private int age; private String name; public void Employee(){ } public Employee(int age){ this.age = age; } public Employee(String name){ this.name = name; } } A: Employee e = new Employee( ) B: Employee e = new Employee(10); C: Employee e = new Employee(tom); D: Employee e = new Employee(10,"tom");
- 中国大学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”) ; } }
- 抽象类A和抽象类Test的定义如下: abstract class A { abstract int getInfo() { } } public class Test extends A { private int a = 0; public int getInfo() { return a; } public static void main(String args[]) { Test b= new Test(); System.out.println(b.getInfo()); } } 关于上述代码说明正确的是_________