98-372 · Question #89
Which is a set of objects that share the same properties and behavior and is the instinctive view of a "kind" of objects?
The correct answer is A. Class. A class is a set of objects that share the same properties and behavior. It is the instinctive view of a kind of objects. A class is a construct used as a blueprint/template to create objects of that specific class. The blueprint describes the state and behavior shared by all…
Question
Which is a set of objects that share the same properties and behavior and is the instinctive view of a "kind" of objects?
Options
- AClass
- BInheritance
- CInterface
- DAttribute
How the community answered
(33 responses)- A79% (26)
- B3% (1)
- C12% (4)
- D6% (2)
Explanation
A class is a set of objects that share the same properties and behavior. It is the instinctive view of a kind of objects. A class is a construct used as a blueprint/template to create objects of that specific class. The blueprint describes the state and behavior shared by all the objects of the class. An object of a specific class is known as an instance of the class. The class that consists of that instance can be considered as the type of that object, e.g., an object instance of the "AutoMobile" class will be of "AutoMobile" type. A class represents a noun, such as a person, place, or an abstract thing. It is a model of a concept inside a computer program. It is used to encapsulate the state and behavior of the concept that it exposes through data placeholders called attributes, and to encapsulate behavior through reusable sections of code known as methods. Answer: C is incorrect. An interface, also known as contract, describes a group of related behaviors that can belong to a class or a struct. It can be defined by using the interface keyword in C# language specification. It consists of methods, properties, events, and/or indexers. A class or a struct can inherit multiple interfaces and a single interface itself can also be inherited from more than one interface. When any class or struct inherits an interface, it inherits only the method names and signatures. Interfaces are left completely unimplemented, i.e., no method in the interface is implemented. All methods of an interface are public and are abstract, but the method body is absent. The structure of the IComparable interface of the System namespace is as follows: interface IComparable int CompareTo(object obj1); Answer: D is incorrect. An attribute is a data element that exists in every object of a class. It is represented by a specific value in each object. Attributes have no identity outside the object to which they belong. Attributes are controlled by those objects of which they are a part. An attribute is a role that a property takes. An attribute represents a data definition for an instance of a classifier. It describes a range of values for that data definition. A classifier can have any number of attributes or none at all. Attributes describe the structure and value of an instance of a class. Each attribute is described by its name. Answer: B is incorrect. Inheritance is the technique to classify and reuse code by creating collections of attributes and behaviors called objects, that can be based on the earlier created objects. In traditional inheritance, classes define objects and they can inherit other classes. The new class called sub-class/derived class, inherits attributes and behaviors of the existing classes called super classes or ancestor classes. The inheritance relationship of a class gives rise to a hierarchy. Objects can be defined directly from other objects without defining classes in prototype-based programming. Inheritance is the ability of classes to inherit other classes and makes reuse of code possible. When a class file inherits from another class, it inherits all its members (variables and methods). Different languages use different terms to categorize the two parties in inheritance.
Topics
Community Discussion
No community discussion yet for this question.