Category Archives: Java

Java Program Switch or Swap Arrays

Java Program Switch or Swap Two Arrays – In this program we will swap the given arrays a and b. How This Program Will Work? First of all we will check if the length that is size of the given two arrays is equal or not. If the size of arrays is equal then we can… Read More: Java Program Switch or Swap Arrays »

Loading

Java Simple Calculator Program Using Switch

Java Simple Calculator Program Using Switch statement – We will write a simple Java calculator program. This  program will start by taking input from the user – two numbers and one operator. The operator will be from basic four operations like addition, subtraction, multiplication and division (+, – , * , / ). Source Code… Read More: Java Simple Calculator Program Using Switch »

Loading

Create New Java Class Calculation Add Subtract

Java Program – Create a new class Calculation with add() and subtract methods to add two numbers and to subtract two numbers. Write down a Java Program to Design a Calculation Class with the following features: Define two instance variables num1, num2 of type double. Define two constructors – default constructor to initialize num1 and… Read More: Create New Java Class Calculation Add Subtract »

Loading

Java Vowel Count in String Program

Task: Write a Java program to count vowels in a given string input by the user at runtime. The Source Code of Java Vowel Count Program /* * Write down a Java program to input a string. * And count number of Vowels in it. */ package countvowelsinstring; import java.util.Scanner; /** * * @author www.EasyCodeBook.com… Read More: Java Vowel Count in String Program »

Loading

Java Palindrome String Check

Task: Write down a Java String Program to check for Palindrome. The Source Code of Java Program Check for Palindrome import java.util.Scanner; /** * * @author www.EasyCodeBook.com */ public class StringPalindrome { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print(“Enter a String to check for Palindrome: “); String s1=input.nextLine(); String s2=””;… Read More: Java Palindrome String Check »

Loading

Java String Class Reverse Program

Task: Write a Java String Class Reverse Program. You have to use only String class objects and String class built-in methods to reverse a user supplied string. Logic behind Java String Reverse Program You will use the following standard methods provided in String class: length() method to know the length of the original string. charAt(index)… Read More: Java String Class Reverse Program »

Loading

Java Day Number to Name switch Program

Task: Java Day Number to Name switch Program Java Program – The Use of Switch Statement through practical Java programming- Input a day number from the user Display Day Name. Source Code – Java Day Number to Name switch Program /* * Java Program – The Use of Switch Statement * Input a day number… Read More: Java Day Number to Name switch Program »

Loading

Creating New Box class in Java

Task: Write a Java program to create a new Box class in Java. Use three instance variables width, height and depth of type double. Write down two constructors. Default ( no-arg )constructor will intialize the Box class objects with 0.0 value for all instance variables. A parameterized constructor will be used to intialize the object… Read More: Creating New Box class in Java »

Loading