Posts

📢 Join My WhatsApp Channel JavaWithSumit

Get Daily ICSE Java Notes, Programs & Exam Tips 🚀

👉 Join Now

ICSE Java Programs Part-I | Basic Input Output & Conditional Programs with Solutions

Input/ Output Based Programs Question 1: WAP in Java to accept different type of data as input from Scanner class and print. Solution:  import java.util.Scanner; class DifferentDataTypes { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter an Integer: "); int i = sc.nextInt(); System.out.print("Enter a Float: "); float f = sc.nextFloat(); System.out.print("Enter a Double: "); double d = sc.nextDouble(); System.out.print("Enter a Long: "); long l = sc.nextLong(); System.out.print("Enter a Byte: "); byte b = sc.nextByte(); System.out.print("Enter a Short: "); short s = sc.nextShort(); System.out.print("Enter a Character: "); char ch = sc.next().charAt(0); sc.nextLine(); // Clear buffer System.out.print("En...

User Defined Methods in Java Class 10 | All Programs with Output

Chapter 3: User Defined Methods Question 1: WAP in Java to create a method to accept any two values from the user and multiply them. Store and display the result. Solution:  import java.util.Scanner; class MultiplyValues { // Method to multiply two numbers void multiply(int a, int b) { int result = a * b; System.out.println("Multiplication = " + result); } public static void main(String args[]) { Scanner sc = new Scanner(System.in); // Creating object MultiplyValues obj = new MultiplyValues(); // Accepting values from user System.out.print("Enter first value: "); int x = sc.nextInt(); System.out.print("Enter second value: "); int y = sc.nextInt(); // Calling method obj.multiply(x, y); } } Input: Enter first value: 10 Enter second value: 2 Output: Multiplication =20 Question 2:  WAP for method overloading by creating a method ...

Top Java OOP Programs with Output | Class Variable, Encapsulation, Employee Salary, Basic Java Programs

Chapter 2: Programs  Question 1: WAP to add two integers by using class variable. Solution:  class AddNumbers { static int num1 = 10; static int num2 = 20; static int sum; public static void main(String[] args) {          sum=num1+num2; System.out.println("Sum= "+sum); } } Output: 30 <> Question 2:  WAP to subtract a float number from an integer number and get the result in integer by using local variable. Solution:  class Subtract { public static void main(String[] args) { // Local variables int num1 = 20; float num2 = 5.5f; // Subtraction and type casting to integer int result = (int)(num1 - num2); // Output System.out.println("Result = " + result); } } Output: 14 Question 3:  WAP to print your name by creating an object. Solution:  class MyName { // Method to print name void disp...

Important Java Programs for Beginners | Grade, Fibonacci, Armstrong, Pattern & More

Chapter 1: Programs  Question 1: WAP to check if a number input by the user is even or odd. Solution:  import java.util.Scanner; class EvenOdd { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter a number: "); int n = sc.nextInt(); if(n % 2 == 0) System.out.println("Even Number"); else System.out.println("Odd Number"); } } Input: n=8 Output: Even Number Question 2:  WAP to check if a letter input by user is vowel or consonant. Solution:  import java.util.Scanner; class VowelConsonant { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter a letter: "); char ch = sc.next().charAt(0); ch = Character.toLowerCase(ch); if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') ...