皮皮学,免费搜题
登录
搜题
【简答题】
Classes and Inheritance 1 Classes How are objects defined? An object is defined via its class,which determines everything about an object.Objects are individual instances of a class.A method is simply the action that a message carries out.It is the code,which gets executed when the message is sent to a particular object. Classes serve as templates from which objects can be created.C1asses have the same instance variables and operations as corresponding objects but their interpretation is different.Instance variables in an object represent actual variables while class instance variables are potential,being instantiated only when an object is created.We may think of a class as specifying a behavior common to all objects of the class.The instance variables specify a structure (data structure) for realizing the behavior.The public operations of a class determine its behavior while the private instance variables determine its structure.Private copies of a class can be created by a make-instance operation,which creates a copy of the class instance variables that may be acted on by the class operations.Syntactically,a class can be represented as: name:class instance variables ... class variables ... instance methods ... class methods ... Classes specify the behavior common to all elements of the class.The operations of a class determine the behavior while the instance variables determine the structure. 2 Inheritance In the world at large,it is often possible to arrange concepts into an inheritance hierarchy——a hierarchy in which each concept inherits the properties of the concept immediately above it in the hierarchy. For example, we might classify different kinds of vehicles according to the inheritance hierarchy in Figure 5-3. Moving down the hierarchy, each kind of vehicle is more specialized than its parent (and all of its ancestors) and is more general than its child (and all of descendants). A wheeled vehicle inherits properties common to all vehicles (it holds one or more people and carries them from place to place) but has an additional property that makes it more specialized (it has wheels). A car inherits properties common to all wheeled vehicles but also has additional, more specialized properties (four wheels, an engine, a body, and so forth). The inheritance relationship can be viewed as an is-a relationship.Every two-door car is a car,every car is a wheeled vehicle,and every wheeled vehicle is a vehicle. Inheritance allows us to reuse the behavior of a class in the definition of new classes.Subclasses of a class inherit the operations of their parent class and may add new operations and new instance variables. Inheritance captures a form of abstraction called super-abstraction, that complements data abstraction. Inheritance can express relations among behaviors such as classification, specialization, generalization, approximation, and evolution. The ability to classify classification of classes provides greater classification power and conceptual modeling power. Classification of classes may be referred to as second-order classification. Inheritance provides second-order sharing, management, and manipulation of behavior that complements first-order management of objects by classes. Syntactically, inheritance may be specified in a class as: name:class super class ... instance variables {as before}
拍照语音搜题,微信中搜索"皮皮学"使用
参考答案:
参考解析:
知识点:
.
..
皮皮学刷刷变学霸
举一反三
【单选题】旅客在乘车前丢失车票,应另行买票。在乘车中丢失车票,应从发现丢失车票的车站(如不能判明丢失站时,从())起补收票款,核收手续费。
A.
前方办客站
B.
始发站
C.
后方办客站
D.
发现丢失票站
【单选题】旅客在车站丢失车票,( )。
A.
应免费运送到站
B.
年站应编制农运记承交族农
C.
应另行购票
D.
到站应补收票价,核收手续费
【判断题】旅客在途中丢失车票可凭列车上开具的客运记录出站。
A.
正确
B.
错误
【简答题】历史小说《双城记》是狄更斯最重要的作品之一,在反映作家人道主义思想特点上有代表性。“双城”指法国巴黎和()。
【多选题】道家思想最重要的代表是()
A.
老子
B.
庄子
C.
韩非
D.
李斯
【判断题】( )用数字万用表检测电容器好坏时,将功能旋钮旋到电容档,量程小于被测电容容量。
A.
正确
B.
错误
【单选题】旅客在车站丢失车票,( )。
A.
应免费运送到站
B.
车站应编制客运记录交旅客
C.
应另行购票
D.
到站应补收票价,核收手续费
【简答题】试述向日葵茎的初生结构与玉米茎初生结构的异同。
【判断题】P在核酸中的含量在9%-10%之间。
A.
正确
B.
错误
【多选题】系统不定时蓝屏,最小化系统时以下哪些部件是必要的?
A.
显示器
B.
光驱
C.
硬盘
D.
声卡
相关题目: