類Student代碼如下:D class Student{ String name; int age; Student(String nm){ (構(gòu)造方法) name = nm; } } 執(zhí)行語句Student stu = new Student()后,字段age的值是哪項?()
A. 0 B. null C. false D. 編譯錯誤
現(xiàn)有: Public/project]class TestFoo { int x; String y; int getX() { return x; } (4,5,6是方法) String getY() { return y; } void setX(int x) { int z = 7; this.x = x; } } Private代表屬性封裝可以添加多少個修飾符來封裝此類?()
A.2 B.3 C.4 D.5
public class Pass{ public static void main(String[]args){ int x=5; Pass p=new Pass(); p.doStuff(x); System.out.print("mainx="+x); } void doStuff(intx){ System.out.print("doStuffx="+x++); } } What is the result?()
A.Compilation fails. B.An exception is thrown at runtime. C.doStuff x=6 main x=6 D.doStuff x=5 main x=5 E.doStuff x=5 main x=6 F.doStuff x=6 main x=5