Elementary Concepts of Object Class
[ICSE Syllabus on this Topic “Elementary Concepts of Object Class”]
Modeling entities and their behavior by objects. A class as a specification of objects and as an object factory, computation as message passing/function call between objects (many example should be done to illustrate this). Object encapsulate state (attribute) and have behaviors (functions). Class as a user defined type.
Q. What is an Object?
Ans: An Object is an identifiable entity with some characteristics and behavior. E.g. take a class ‘Car’. A car class has characteristics like colour, gears, power, length etc. now we create the object of that class ‘Car’ namely ‘Indica’.
Q. What is OOP? What are the features/concepts in OOP’s?
Name any two OOP’S principles.
Ans: The Object Oriented Programming Paradigm is the latest in the software development and the most adopted one in the programming development. The Paradigm means organising principle of a program. It is an approach to programming. The concepts of OOP’s are: (1) Data Abstraction (2) Data Encapsulation (3) Modularity (4) Inheritance (5) Polymorphism.
Q. Explain all the Concepts of OOP’s?
Ans: Abstraction: It refers to the act of representing essential features without including the background details or explanation. Encapsulation: It is the way of combining both data and the function that operates on the data under a single unit. Modularity: It is the property of a system that has been decomposed into a set of cohesive and loosely couple modules. Inheritance: It is the capability of one class of thing to inherit properties from another class. Polymorphism: It is the ability for a message or data to be processed in more than one form.
Q. What are the advantages of OOP’s?
Ans: (1) Elimination of redundant coding system and usage of existing classes through inheritance. (2) Program can be developed by sharing existing modules. (3) Possibilities of multiple instance of an objects without any interference. (4) Security of data values from other segment of the program through data hiding.
Q. What is Class? How Object is related to the Class?
Ans: A Class represent a set of Objects that share common characteristics and behavior. Objects are instance of a class. The Object represents the abstraction representation by the class in the real sense.
Q. What is the need of a class in Java?
Ans: Classes in Java are needed to represent real-world entities, which have data type properties. Classes provide convenient methods for packing together a group of logical related data items and functions that work on them. In java the data items are called fields & the functions are called methods.
Q. What are Methods? How are these related to an Objects?
Ans: A Method is an operation associated to an Object. The behavior of an Object is represented through associated function, which are called Methods.
Q. Point out the differences between Procedural Programming and Object Oriented Programming.
Ans: Procedural programming aims more at procedures. The emphasis is a doing things rather then the data being used. In procedural Programming parading data are shared among all the functions participating thereby risking data safety and security. Object Oriented Programming is based on principles of data hiding, abstraction, inheritance and polymorphism. It implements programs using classes and objects, In OOP’s data and procedure both given equal importance. Data and functions are encapsulated to ensure data safety and security.
Q. What is an abstraction?
Ans: An abstraction is a named collection of attributes and behaviors required to represent an entity or concept for some particular problem domain.
Q. What is inheritance and how it is useful in Java.
Ans: It is process by which objects of one class acquire the properties of objects of another class. Inheritance supports the concepts of hierarchical representation. In OOP the concepts of inheritance provides the idea of reusability.
Q. What role does polymorphism play as java feature?
Ans: It mean the ability to take more than one form. For example, an operation, many types of data used in the operation.
Q. What is Data hiding?
Ans: Data Hiding means restricting the accessibility of data associated with an object in such a way that it can be used only through the member methods of the object.
Q. What are nested classes?
Ans: It is possible to define a class within another class, such classes are known as nested classes. A nested class has access to the members including private members of the class in which it is nested. However the enclosing class not have access to the members of the nested class.
Q. Differentiate between base and derived class.
Ans: BASE CLASS – A class from which another class inherits (Also called SUPER CLASS)
DERIVED CLASS – A class inheriting properties from another class. (Also called SUB CLASS)