Skip to main content

#WSQ03 #Java #TC201 Object-Oriented Basics

3 min read

In object oriented programming we approach a poll by trying first to decompose it into budget data types and of course another paradigm you end up defining in your code both, data types and access.

Static language: do type checking at compile time.

Dynamic language: do type checking at run time.

Class: a class is simply a definition other data type and it's class each data type is defined by the members which make it up, members come in two basic kinds fields and methods. is a collection of objects and it is a logical entity.

Fields: are the data members their the data which actually makes up the type

Method: is basically a function associated with that class, 

Object: is a piece of data, instance of a class and has states and behaviors. Any entity that has state and behavior is known as an object.  

Encapsulation: The idea of encapsulation is simply that the fields of an object an instance should only be read or written by method so that instance class. Binding code and data together into a single unit is known as encapsulation. For example: a capsule it is wrapped with different medicines. A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private here.

Polymorphism: when one taks is performed by different ways. For example: to convense the customer differently, in java, we use a method overloading and method overriding to achieve polymorphism.

Inheritance: The idea of inheritance is simply that when one object acquires all the properties and behaviours of parent object, it provides code reusability and it is used to achieve runtime polymorphism.

Abstraction: Hiding details and showing functionality. For example: phone call, we don't know the internal processing. In java, we use abstract class and interface to achieve abstraction.

Constructor: Method which is run in order to set up an instance of classes. How he looks like is context dependent.

Interface: If there are different classes which are not related but share the same set of methods in common, interface can be created to form a bundle of methods which can be used by those classes.


Advantage of OOPs over Procedure-oriented programming language

1)OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grows.

2)OOPs provides data hiding whereas in Procedure-oriented prgramming language a global data can be accessed from anywhere.

3)OOPs provides ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language.

Sources where I learned all this concepts:

Java OOPs Concepts

Object-Oriented Programming