java file
java file
Output
Ques-2 Write a Program to check whether a year is Leap Year or not
Output
**
***
****
Output
Q-4 Write a program in java to Compute the sum of the digits of an integer using
user defined method
Q 5 Write a program to find maximum and minimum number from an array
Q-6 Write a program declaring a class Rectangle with data member’s length and Breadth and member
functions Input, Output and CalcArea
Output
Length-5
Breadth-3
Area=15
Q7 Write a program to demonstrate the use of static variable, static method and static block
Output
Q8 Write a program in java to implement constructor using parameter
Output
Q-9 Write a program to demonstrate use of method overloading to calculate area of square, rectangle
and triangle
Output
Ques 10 Write a program to use super() to invoke base class constructor.
Output
Q11 Write a program to demonstrate the concept of abstract class with constructor and ``final`` method
Output
Q12 Write a Java program to create an interface Shape with the getArea() method. Create three classes
Rectangle, Circle, and Triangle that implement the Shape interface. Implement the getArea() method for
each of the three classes.
class Shape {
double getArea();
this.length = length;
this.width = width;
double radius;
Circle(double radius) {
this.radius = radius;
this.base = base;
this.height = height;
Output
// File: Main.java
import mypackage.MyClass;
obj.displayMessage();
Output
Output
Q-15 Write a Java program to read input from the Java console
Output
Q-16 Write a Java program to create a method that reads a file and throws an exception if the file is not
found.
Output
Q17 Write a Java program to throws user define exception
Output
Q18 Write a Java program that reads a list of integers from the user and throws an exception if any
numbers are duplicates
import java.util.*;
super(message);
if (!uniqueNumbers.add(num)) {
numberList.add(sc.nextInt());
try {
checkForDuplicates(numberList);
} catch (DuplicateNumberException e) {
sc.close();
Output
Q19 Write a Java program to create a basic Java thread that prints "Hello, World!" when executed
Output
Q20 Write a Java program to create multi threading that prints message when executed
Output