Category: JAVA
-
Flowchart
1.Palindrome: 2.Addiion of digits: 3.Count of digits: 4.Armstrong: 5.Decimal to binary: 6.Binary to decimal: 7.Prime number: 8.Least common multiple: 9.Greatest common divisor: 10.Fibonacci series:
-
Conditional statements
Java If-else Statement: The Java if statement is used to test the condition. It checks boolean condition: true or false. There are various types of if statement in Java. if: if statement is the most simple decision-making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true…
-
Getter and Setter
Getter and Setter: Why do we need getters and setters in Java? The primary use of setter and getter is to maintain encapsulation. We require a setter method to update the value of a private variable from outside of the class and a getter method to read the value of that variable. It allows developers…
-
Type casting,Wrapper classes ,Interface
Type casting: Convert a value from one data type to another data type is known as type casting. Types of Type Casting: There are two types of type casting: Widening Type Casting: Converting a lower data type into a higher one is called widening type casting. It is also known as implicit conversion or casting down. It is done automatically. It…
-
Static Block and Non-Static Block
Static Initialization Block in Java: When a block is declared with the static keyword, it is called static block in Java. It is a normal block of code that is enclosed in braces ({ }) and is preceded by a keyword “static”. Static block is also known as static initialization block or static initializer block in Java.…
-
Protected keyword
protected keyword: A Java protected keyword is an access modifier. It can be assigned to variables, methods, constructors and inner classes. The methods or data members declared as protected can be accessed from, Points to remember: Reference: https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html https://www.javatpoint.com/protected-keyword-in-java https://www.baeldung.com/java-protected-access-modifier https://www.geeksforgeeks.org/protected-keyword-in-java-with-examples/ TBD: I didn’t declare any static variable but I got error
-
Difference between
Method overloading and method overriding in java No. Method Overloading Method Overriding 1) Method overloading is used to increase the readability of the program. Method overriding is used to provide the specific implementation of the method that is already provided by its super class. 2) Method overloading is performed within class. Method overriding occurs in two classes that have IS-A (inheritance) relationship.…
-
Method Overriding and Super keyword
Method Overriding: Declaring a method in sub class which is already present in parent class is known as method overriding. Overriding is done so that a child class can give its own implementation to a method (the same name, same parameters or signature, and same return type) which is already provided by the parent class. In this case the…
-
Inheritance
Java Inheritance (Subclass and Superclass): In Java, it is possible to inherit attributes and methods from one class to another. We group the “inheritance concept” (child object/ class behaves like parent object/class) into two categories: To inherit from a class, use the extends keyword. A subclass inherits all the members (fields, methods, and nested classes) from its superclass. Constructors…