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 such a concept in which one object interact with the other object, where the properties of one class can be inherited by another class. It help developer or programmer to reuse code and create a new bond between classes. Two things involved in this process; Parent class (Base
For adding numbers of same type we have to first define the variables. Like in 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 = i
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 below code I generate a set or array of random variables and then I am counting every individual character so in through this programs we can identify the occurrence of each character. To generate Random number we will use 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