给定如下代码,要在第三个构造方法的空白处填上一行代码使之能够调用第二个构造方法,这行代码应该是()
class Circle{
String name,radius;
int r;
public Circle(String n){
name=n;
}
public Circle(String n,int a){
name=n;
r=a;
}
public Circle(String n,String d,int a){
radius=d;
}
}
class Circle{
String name,radius;
int r;
public Circle(String n){
name=n;
}
public Circle(String n,int a){
name=n;
r=a;
}
public Circle(String n,String d,int a){
radius=d;
}
}
举一反三
- (6-2)定义如下Person类,(1)处合理的代码是。 class Person { String name, department; int age; public Person(String n) { name = n; } public Person(String n, int a) { name = n; age = a; } public Person(String n, int a, String d) { ① department = d; } }
- 中国大学MOOC: public class Person { String name,department; int age; public Person(String n){name=n;} public Person(String n,int a){name=n; age=a;} public Person(String n, String d, int a ){ //调用2个参数的构造函数 department=d; }}
- 4.6 若有以下程序代码: class Person{ String name,department; int age; public Person(String n){name=n;} public Person(String n, int a){name=n; age=a;} public Person(String n, String d, int a ){ //执行此代码 } 下面那个选项可以添加到“//执行此代码”前面( )
- 请填写代码 public class Teacher { int age=33; private string name; public string Name { get{请在此处填上代码} set{请在此处填上代码} } } public void SaySomething{ //….. }
- 【多选题】给出如下代码 //接口 public interface Info { String show(int m, int n); } //类 public abstract class implements Info{ —————————— } 问:在类划线处,下列哪些定义是合法的?() A. public String show(int m, int n) {} B. public void show(int m, int n) {} C. protected String show(int m, int n) {} D. public Object show(int m,int n) {} E. public abstract String show(int m, int n); F. 其他定义都不合法