Posts

Showing posts from March, 2023

Type Casting

 Type Casting Type Casting:                    Converting one data type into another data type is knowns as Type casting. All the 8 primitives datatype except boolean we can convert from one datatype to another datatype. Types of Type casting: Inplicit type casting Explicit type casting 1. Implicit type casting: It is a process of Converting smaller datatype to larger datatype is known as Implicit type casting. It is also known as Widening. Implicit type casting is done by compiler automatically. There is no loss of information in implicit type casting. 2. Explicit type casting:  It is a process of converting larger datatype to smaller datatype is known as Explicit type casting. It is also known as narrowing. Explicit type casting will not be performed by the compiler, it is the responsibility of the programmer. There may be chance of loss of information. Byte-> short, int, long, float, double. short-> int, long...

Exception Handling

 Exception Handling Exception:                If there is an exception in our program, the program will be terminated. But we can save program by using exception handling techniques. Types of Exception: Checked Exception: The exception which are detected at compilation time by JVM are known as Checked exception. Unchecked Exception: The exception which are detected at run time by JVM are known as Unchecked Exception. Error:               If there is an error in your program, the program will be terminated. We can't save our program. Types of Error: Compile time Error: These errors occurs due to wrong syntax. Runtime Error: These errors occurs due to inefficiency of the machine. Logical Error: These errors are occurs due to bad login in program. Key points In Exception Handling: If we are writing try-catch-finally blocks then we should maintain the order. try-catch-finally   ---> Val...

OOP's Concepts

Image
 OOP's Concepts: Class Object Encapsulation Inheritance Polymorphism Abstraction 1. Class:                  Class is a collection of objects.  Class is a blueprint which defines some properties and behaviors.  It is logical entity. 2. Object:                 Any real world entity which has behavior and state known as Object. It is logical or physical entity. For Ex. chair, book, computer, bottle etc. 3. Encapsulation:               It is a process of wrapping up of data or binding up of data into a single unit, known as encapsulation. For Ex. Capsule(wrapped with different medicines).               It is a process of making fields as private and providing access to those fields with the help of public methods that is through setters and getters methods. 4. Inheritance:       ...

Access Specifiers in Java

Image
 Access Specifiers In Java, there are 4 types of Access Specifiers:      A. Class Level:      1. If class is declared as public then that class is visible to all the classes everywhere inside that project.      2. If the class is declared as default (package private) then that is visible to the classes which are present in the same package. B. Member Level:     At member level we can use all the four access modifiers. 1. Public:  If a method, variable or constructor is declared as public then we can access them from anywhere. When we are accessing the public member its class also should be public otherwise will be getting compile time error. 2. Default: If a method, variable or constructor is declared as default then we can access them from current package only. So it is also called "PACKAGE-PRIVATE". 3. Private:  If a method, variable or constructor is declared as private then we can access them in the current class ...