Most common asked questions for java, Cheat Sheet of Object Oriented Programming

These questions was taken from our Final exam of JAVA

Typology: Cheat Sheet

2020/2021

Uploaded on 07/01/2021

soul-recto
soul-recto 🇵🇰

5

(1)

6 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ENCAPSULATION:
Encapsulation is one of the fundamental concepts in object-oriented
programming (OOP). It describes the idea of bundling data and methods that work
on that data within one unit, e.g., a class in Java.This concept is also often used to
hide the internal representation, or state, of an object from the outside. This is
called information hiding .
Abstraction:
Abstraction is one of the key concepts of object-oriented programming (OOP)
languages. Its main goal is to handle complexity by hiding unnecessary details
from the user. That enables the user to implement more complex logic on top of
the provided abstraction without understanding or even thinking about all the
hidden complexity.
Inheritance:
Inheritance is one of the core concepts of object-oriented programming (OOP)
languages. Inheritance is new code that reuses old code. It is a mechanism where
you can to derive a class from another class for a hierarchy of classes that share a
set of attributes and methods.
Polymorphism:
Polymorphism is old code that reuses new code.Polymorphism describes the
concept that objects of different types can be accessed through the same interface.
Each type can provide its own, independent implementation of this interface. It is
one of the core concepts of object-oriented programming (OOP).
How is an object different from a class?
An object is a member or an "instance" of a class. An object has a state in which all
of its properties have values that you either explicitly define or that are defined by
default settings. Whereas A class is a template for objects. Class specifies the
characteristics of an entity but is not an instance of that entity.A class defines
object properties.Much like a blue print that specifies the characteristics of a
building.
How is abstraction different from encapsulation?
Abstraction is the method of hiding the unwanted information. Whereas
encapsulation is a method to hide the data in a single entity or unit along
pf2

Partial preview of the text

Download Most common asked questions for java and more Cheat Sheet Object Oriented Programming in PDF only on Docsity!

ENCAPSULATION:

Encapsulation is one of the fundamental concepts in object-oriented programming (OOP). It describes the idea of bundling data and methods that work on that data within one unit, e.g., a class in Java.This concept is also often used to hide the internal representation, or state, of an object from the outside. This is called information hiding. Abstraction: Abstraction is one of the key concepts of object-oriented programming (OOP) languages. Its main goal is to handle complexity by hiding unnecessary details from the user. That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity. Inheritance: Inheritance is one of the core concepts of object-oriented programming (OOP) languages. Inheritance is new code that reuses old code. It is a mechanism where you can to derive a class from another class for a hierarchy of classes that share a set of attributes and methods. Polymorphism: Polymorphism is old code that reuses new code.Polymorphism describes the concept that objects of different types can be accessed through the same interface. Each type can provide its own, independent implementation of this interface. It is one of the core concepts of object-oriented programming (OOP). How is an object different from a class? An object is a member or an "instance" of a class. An object has a state in which all of its properties have values that you either explicitly define or that are defined by default settings. Whereas A class is a template for objects. Class specifies the characteristics of an entity but is not an instance of that entity.A class defines object properties.Much like a blue print that specifies the characteristics of a building. How is abstraction different from encapsulation? Abstraction is the method of hiding the unwanted information. Whereas encapsulation is a method to hide the data in a single entity or unit along

with a method to protect information from outside. Abstraction is the process or method of gaining the information.While encapsulation is the process or method to contain the information. In abstraction, implementation complexities are hidden using abstract classes and interfaces. While in encapsulation, the data is hidden using methods of getters and setters. What is the key advantage associated with the inheritance mechanism? Inheritance is new code that reuses old code. A key advantage of inheritance is that it allows you to reuse code from a base class yet leave the existing code unmodified. Moreover, inheritance requires no changes to the way that other classes interact with the base class. Rather than modifying an existing class using inheritance you can treat that class as an integrated module that you can extend with additional properties or methods.