单项选择题
You want to limit access to a method of a public class to members of the same class. Which access accomplishes this objective?()
A. public
B. private
C. protected
D. transient
E. default access
点击查看答案&解析
相关考题
-
单项选择题
publicclassTest{ publicstaticvoidmain(String[]args){ intx=0; assert(x>0):“assertionfailed”; System.out.println(“finished”); } } Whatistheresult?()
A. finished
B. Compilation fails.
C. An AssertionError is thrown.
D. An AssertionError is thrown and finished is output. -
单项选择题
classSuper{publicintgetLenght(){return4;}}publicclassSubextendsSuper{publiclonggetLenght(){return5;}publicstaticvoidmain(String[]args){Supersooper=newSuper();Subsub=newSub();System.out.println(sooper.getLenght()+“,”+sub.getLenght());}}Whatistheoutput?()
A. 4,4
B. 4,5
C. 5,4
D. 5,5
E. Compilation fails. -
单项选择题
public void test(int x) { int odd = x%2; if (odd) { System.out.println(“odd); } else { System.out.println(“even”); } } Which statement is true?()
A.Compilation fails.
B. “odd” will always be output.
C. “even” will always be output.
D. “odd” will be output for odd values of x, and “even” for even values.
E. “even” will be output for add values of x, and “odd” for even values.
