Class, Object in Java
Class, Object in Java
PROGRAMMING CONCEPTS
3. What is Procedure Oriented Programming (POP) ? Name the approach it follows. Give examples.
4. What is Object Oriented Programming (OOP) ? Name the approach it follows. Give examples.
A programming paradigm in which data and functions are bind together in a single unit called
class is known as Object Oriented Programming (OOP).
It follows bottom-up approach.
Examples – C++, C#, JAVA.
A class is used to describe a group of objects that have some common attributes and behaviour.
For example, lion, cows, dogs all have common attributes like eyes, legs, tails and common
behaviour like eat, sleep, walk. Hence they all can be grouped under single unit called known as
Animals.
11. What is the relationship between class and object?
OR
Explain the phrase “Everything is an object”.
A class can be thought of as a template or blueprint for multiple objects with similar features. An
object belonging to a particular class is known as instance of a class. For example, we can say
that Mango is an instance of the Fruit class.
Abstraction refers to the act of representing essential features without including background details.
The user interacts with only the essential features and rest of the complex parts are hidden from the
user.
Encapsulation is the mechanism that binds the data and functions together in a single unit called
class and hence keep them safe from outside world by preventing unauthorized access or misuse.
Inheritance is a powerful mechanism by which a class acquires the properties of another class. It
allows a class to inherit the attributes and behavior of its parent class.
Polymorphism is the ability of a function or an object to take multiple forms. In OOP, polymorphism
allows different funtions to exhibit different behavior in different instances.
Using abstraction, the objects expose only the essential features to the outside world and hide the
rest of the details. The outside world sees a simplified version of the actual object. This is called data
hiding.
18. State 4 differences between Procedure Oriented Programming (POP) and Object Oriented
Programming (OOP).
3. Data and functions are separate. 3. Data and functions are bind in a single entity.
4. Example – C, COBOL, PASCAL 4. Example - Java, C++, C#
Classes can be derived from other classes using the concept of inheritance. The class that is derived
from another class is called subclass. The class from which its derived is called superclass.