Posts

Showing posts from February, 2022

Interface and Abstract Class in Java

Image
Overview Q&A Whenever we are creating a Child class object whether Parent class object will be created or not? Whenever we are creating Child class object automatically Parent constructor will be executed to perform initialization for the instance variables which are inheriting from parent. But it will not create an object of Parent class. It will create the object of only the Child class. Whenever we are creating a Child class object what is the need of executing Parent class constructor? Child class constructor is used to initialize child class properties and Parent class constructor is used to initialize Parent class properties. When you are calling the Child class constructor you have to call Parent class constructor with the help of super keyword. If not the compiler will prompt compile time error. In the below program InterfaceAndAbstractMain  both Parent and Child constructor are executed for Child object initialization only. Note: Whenever we are creating Child class object

Language Fundamentals in Java

Image
Overview Language Fundamentals Identifiers - A name in Java Program is called an Identifier. Which can be used for identification purpose. It can be method name, or variable name of class name or label name. The characters allowed in an identifier are A-Z, a-z, 0-9, _ and $. Rest other characters will give you a compile time error. An identifier must not start with a digit. An identifier is case sensitive and it can have n number of characters. Reserved Words - There are 53 reserved words available in Java.  Keywords (50) Used Keywords (48) Data types byte short int long float double char boolean Conditions if else switch case default do while for break continue return Modifiers public private protected static final abstract synchronized native transient volatile strictfp Exception try catch finally throw throws assert Class class interface extends implements package import Object new instanceof super this Return type void Unused Keywords (2) - goto and const Reserved Literals (3)