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()); } } 关于上述代码说明正确的是_________
内容
- 0
在下面的类中那个是合法的覆盖()class Base{public void mehod(int k)}class Sub{} A: private void mehod(int k) B: public void mehod(int y) C: public void mehod() D: public int mehod(int k)
- 1
//Animal类 public class Animal{ int age; public void eat(){ System.out.println("动物具有东西的能力"); } public void sleep(){ System.out.println("动物也会睡觉"); } } //Dog类继承Animal类 public { //重写eat方法,将输出内容改成"狗具有吃东西的能力" { } public void dogsleep(){ //调用父类sleep方法 } } public class Test(){ //父类引用指向本类对象,创建对象obj1 //父类引用指向子类对象,创建对象obj2 }
- 2
以下的类(接口)定义中正确的是( ) A: public class A{ private int x; public getX(){ return x; }} B: public abstract class A{ private int x; public abstract int getX(); public int aMethod(){ return 0; }} C: public class A{ private int x; public abstract int getX();} D: public interface interfaceA{ private int x; public int getX(){ return x; }}
- 3
下面程序运行结果为___________________。public class MyClass{ private static int a = 19; public static void modify(int a){ a = a + 5;} public static void main(String[] args){ modify(a); System.out.println(a); }}
- 4
下列哪些函数功能是对全局表进行修改?( ) A: gettablestr(tablename, row, col) B: settablestr(tablename, row, col, “string”) C: gettablenum(tablename, row, col) D: settablenum(tablename, row, col, value)