Category Java

(Exception Handling and Multithreading) a) Write a program that reads two numbers from the user to perform integer division into Num1 and Num2 variables. The division of Num1 and Num2 is displayed if they are integers. If Num1 or Num2 were not an integer, the program would throw a NumberFormatException. If Num2 were Zero, the program would throw an ArithmeticException.

//Program to throw implement division and throw exceptions import java.util.*; class NAexception {             public static void main(String args[])             {                         Scanner scr=new Scanner(System.in);                         int num1,num2,q;                         try                         {                                     System.out.println(“nEnter the value of first integer :…

(packages) Design a package to contain the class Student that contains data members such as name, roll number and another package contains the interface Sports which contains some sports information. Import these two packages in a package called Report which process both Student and Sport and give the report.

package pack1; public class Student {                                                          public int rol_no=18;                         public char name[]={‘s’,’e’,’k’,’h’,’a’,’r’}; }                                     package pack2; public interface Sports {             void show();                                     }             //Program to implement packages package Record; import pack1.*; import pack2.*;…

Enable Notifications OK No thanks