Abstraction is to hide unnecessary details from the user and to show only relevant things/data to the user. Abstract class: Abstract class in Java contains the abstract keyword. If a class is declared abstract, it cannot be instantiated, means that you cannot create an object of an abstract class. Also, an abstract
Encapsulation is a technique in which you can bind your data and code together as a single unit. It’s a good approach to hide your data to make it safe from any modification. The best way to understand encapsulation is to look at the example of a medical capsule, where the
Inheritance is a concept in which one object interacts with the other object, where the properties of one class can be inherited by another class. It helps developer or programmer to reuse code and create a new bond between classes. Two things are involved in this process; Parent class (Base
For adding numbers of the same type we have to first define the variables. Like in the below code we define two variables of type int. int i=5; int j=10; int sum = i + j; System.out.println(sum); For adding numbers which have different types; int i=5; float j=10; float sum
Below programs display the pyramid of numbers based on user input // Library to import import java.util.Scanner; Scanner input = new Scanner (System.in); // for taking input from user System.out.println("Enter the Input Number that how many times do you want to get pyramid of numbers : "); int inputNumber =
How to count characters from a set of variables in Java?How to count characters from a set of variables in Java?
In the below code, I generate a set or array of random variables and then I am counting every individual character so in through this program we can identify the occurrence of each character. To generate Random numbers we will use a random library of Java to generate random alphabets
In cryptography, a Caesar cipher, also known as Caesar’s cipher, the shift cipher, Caesar’s code or Caesar shift, is one of the simplest and most widely known encryption techniques. Lets implement this; //First we take input of word Scanner input = new Scanner (System.in); System.out.println("Enter Word"); String word=input.nextLine(); //Then we take input for steps or we can say that