Class 10 ICSE - Java Library Method Programs

Class 10th Java aims to empower students by enabling them to build their own applications introducing some effective tools to enable them to enhance their knowledge, broaden horizons, foster creativity, improve the quality of work and increase efficiency.
It also develops logical and analytical thinking so that they can easily solve interactive programs. Students learn fundamental concepts of computing using object oriented approach in one computer language with a clear idea of ethical issues involved in the field of computing
Class 10th java topics includes revision of class 9th, constructors, user-defined methods, objects and classes, library classes , etc.
Program 1: Write a program to print the square root of first four consecutive integers.
Solution:
class sqrt {
public static void main(String[] args) {
for (int i = 1; i <= 4; i++) {
System.out.println("Square root of " + i + " is: " +Math.sqrt(i));
    }
  }
} 
                    


Program 2: Write a program to print the cube root of first four consecutive integers.
Solution:
  class cbrt {
    public static void main(String[] args) {
    for (int i = 1; i <= 4; i++) {
        System.out.println("Square root of " + i + " is: " +Math.cbrt(i));
    }
  }
}
                        

Program 3: Write a program to input two numbers and print which one is largest
Solution:
  import java.util.*;
  class max {
      public static void main(String[] args) 
      {
          System.out.println("Enter two numbers");
          Scanner sc = new Scanner(System.in);
          int a=sc.nextInt();
          int b=sc.nextInt();
          System.out.println("largest no.=" +Math.max(a,b));
      
    }
  }
                        

                        


Program 4: Write a program to input two numbers and print which one is smallest
Solution:
  import java.util.*;
  class min {
      public static void main(String[] args) 
      {
          System.out.println("Enter two numbers");
          Scanner sc = new Scanner(System.in);
          int a=sc.nextInt();
          int b=sc.nextInt();
          System.out.println("largest no.=" +Math.min(a,b));
      
    }
  }
                        

Program 5: Write a program to print the square of first 10 positive integers
Solution:
    class sq {
        public static void main(String[] args) {
            int k = 2;
        for (int i = 1; i <= 10; i++) {
           
            System.out.println("Square of " + i + " is: " +Math.pow(i,k));
        }
      }
    }
                          
                        

                        


Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com