Posts

Showing posts from May, 2026

📢 Join My WhatsApp Channel JavaWithSumit

Get Daily ICSE Java Notes, Programs & Exam Tips 🚀

👉 Join Now

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...