Posts

Showing posts from April, 2025

OOPS 2 - Encapsulation (access modifiers and constructors)

Image
 OOPS Access Modifiers: Define the level of protectiveness. Please use below link to download access modifier package for practice. https://github.com/PuneetKumarSinghIT/java.git Constructors: The first method which will trigger whenever you are creating an object of an class. It will define memory for your class object as class is a blueprint and object is real look of that blueprint which live. Java will cancel default constructor once you create one of your own parameters list. Responsibility of constructors: Create object of a class. assign default values to attributes of a class. example: int x =0; -> primitive datatype Integer x = null; -> class So constructor responsibility of constructor is to assign default values if datatype is promitive and null if datatype is derived or wrapper class object. Syntax to create a constructor: class puneet{ public puneet() { } } You can have paremeters or not for your constructor, calling your constructor will be done at the time of o...

OOPS concept 1

Image
OOPS concept part1  OOPs is a programming paradigm. It is a type/way of writing code. Some of the paradigms are: Procedural OOPs Functional Procedural paradigm: Set of some instructions or set of some functions. Each function internally call another function and program will start from very special function/procedure called as main. In this process you need to call main function and it will call all other functions. main function is a trigger point of your program. Organize code in set of functions and each functions can call another function and each program run from special function called main. Issues: Not connected to real world -  It cannot tell that if something is happining to someone. As it don't work on objects and their behaviour and don't help to work on their emotions. You cannot have flexibility in passing parameters to a function once function signature is defined. If have too many parameters to a function then cannot manage them and it will become messy. We can ...