A: 将private int m() 改为protected int m()
B: 将private int m() 改为 public int m()
C: 将private int m() 改为 static int m()
D: 将private int m() 改为 int m()
举一反三
- 给出下列代码,如何使成员变量m被方法fun()直接访问?class Test { private int m; public static void fun( ) { ... }} A.将 private int m 改为protected int m B.将private int m 改为public int m C.将private int m改为static int m D.将private int m改为int m
- 给出下列代码,如何使成员变量m 被方法fun()直接访问? class Test { private int m; public static void fun() { } }
- public class test { public static void main(String args[]) { int m=0; for ( int k=0;k<2;k++) method(m++); System.out.println(m); } public static void method(int m) { System.out.print(m); } }
- class Person {private int a;public int change(int m){ return m; }}public class Teacher extends Person {public int b;public static void main(String arg[]){Person p = new Person();Teacher t = new Teacher();int i;// point x}}在 // point x安排哪个语句合法?
- 有以下程序 #include int m=12; int fun( int x,int y ) { static int m=3; m= x * y - m ; return (m); } main() { int a=7, b=5; m=fun( a, b )/m; printf("%d\n", fun( a, b )/m ); } 程序运行后的输出结果是
内容
- 0
下列函数原型声明中,错误的是________。 A: int fun(int m, int n); B: int fun(int, int); C: int fun(int m=3, int n); D: int fun(int &m, int &n);
- 1
【多选题】给出如下代码 //接口 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. 其他定义都不合法
- 2
下列代码的输出结果是( )interface Com{ int M=100; int on();}class A implements Com{ public int on(){ return Com.M; }}public class E{ public static void main(String args[]){ Com com=new A(); int m=com.on(); System.out.println(m); }}
- 3
下面哪个函数是public void aMethod(){...}的重载函数? A: public int aMethod(){...} B: public aMethod(){...} C: public int aMethod ( int m){...} D: int aMethod ( int m){...}
- 4
已有如下程序: class Person{ private int a; public void change(int m){a=m;} } public class Teacher extends Person { public int b; public static void main(String args[]){ Person p=new Person(); Teacher t=new Teacher(); int i; _____________________ } } 下面划线处填写的语句那些是非法的操作 提示:考查内容包括静态成员,私有成员,继承等知识点