Posts

Inheritance and Polymorphism

Image
 Inheritance and Polymorphism Inheritance (Hierarchy): Constructor chaining: Git link for code: https://github.com/PuneetKumarSinghIT/java Super Keyword usage: If a person want to call specific constructor of his super class means parent which is inherited by that perticular class then that child class need to give super(parameter) to call the constructor of parent class. Please follow git repo for detailed code: https://github.com/PuneetKumarSinghIT/java The super keyword in Java is a powerful tool used to refer to the immediate parent class. It is especially useful in class inheritance scenarios.  Accessing Parent Class Methods ( Method Overriding Context): Why it's useful: When you override a method but still need to invoke the parent's   implementation (e.g., to extend or augment behavior), super.methodName() is essential. Accessing Parent Class Data Members(Variable Shadowing Context): Why it's useful: Avoids ambiguity and allows access to hidden fields from the p...

Java installation for VSCode

 Java in VS Code Download Java extension in VS code as package it will install all dependencies as well like Maven and Gragle for Java. You can create a Java project and can select for Maven project quickguide and then fillt he information and select the destination folder and it will make the think ready for you. Maven will work like charm and will install all dependencies as per expectation. To add any new dependencies into your java project you need to edit POM file and need to add new dependies under dependencies tag if it is not present in your POM and create one. Once dependencies tag is added to POM file VS code will ask for sync your config file press yes for it. It will help to build java project and test it by using VS code test icon. Junit will help you to write test classes and you can call your code method to test for desired result and can modify the code to check edge cases. For debugger you can work with your class code which has main function and then you can debug...

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 ...