A . Make the instance data private
B . Define the methods in the class to access and manipulate the instance data
C . Make the methods of the class public
D . Make the class final
E . All of the above preserve encapsulation
D,封装意味着类包含操做数据所需的数据和方法。为了正确地保留封装,实例数据不该该直接从类外部访问,所以实例数据被设为私有,并定义方法来访问和操做实例数据。此外,访问和操做实例数据的方法被公开,以便其余类可使用该对象。保留字“最终”用于控制继承,与封装无关。html
A . it will produce a syntax error when compiled
B . it must be a void method
C . it can not be called from outside the class that defined the method
D . it must be defined to be a public method
E . it must be an int, double, float or String method
B,全部的方法都是隐含的,所以必须有一个return语句。可是,若是程序员但愿编写一个不返回任何内容的方法,所以不须要返回语句,那么它必须是一个void方法(其头具备void做为其返回类型的方法)。java
A . m1
B . m2
C . m3
D . m5
E . main
B,方法终止后,控件将继续使用调用该方法的方法。在这种状况下,m2调用m4,这样当m4终止时,m2将恢复git
A . public, private
B . public, private, protected
C . public, private, protected, final
D . public, protected, final, static
E . public, private, protected, static
B,public、private和protected控制变量和方法的可见性。final控制变量、方法或类是否能够进一步更改或重写为不可见。静态控制变量或方法是否与类的实例或类自己关联。程序员
A . You'll likely receive a syntax error
B . The program will compile with a warning, but you'll get a runtime error
C . There's nothing wrong with declaring a constructor to be void
D . The class' default constructor will be used instead of the one you're declaring
E . None of the above
A,声明任何类型的构造函数为偶数void都是违反语法的,这样会收到语法错误数据结构
A . true
B . false
A,语法错误的缘由是它以“;”符号结尾。它后面须要{},括号内有0条或更多指令。抽象方法将以“;”结尾,但此头不定义抽象方法。app
代码行数(新增/累积) | 博客量(新增/累积) | 学习时间(新增/累积) | 重要成长 | |
---|---|---|---|---|
目标 | 10000行 | 30篇 | 400小时 | |
第一周 | 138/138 | 2/2 | 25/25 | 学会写和上传代码,会编简单的输出程序 |
第二周 | 88/226 | 1/3 | 30/55 | 起文件名不能太长 |
第三周 | 898/1124 | 2/5 | 35/90 | Java类里面的方法和C语言的函数很像 |
第四周 | 632/1756 | 2/7 | 30/120 | 能够用继承extends简化重复的代码 |