JAVA Practicle (Nizamuddin Sameer)
JAVA Practicle (Nizamuddin Sameer)
**
***
****
System.out.println("HELLO KARAN");
Output:-
HELLO KARAN
Ques-3 Write a program to display the given pattern using nested Loop
*
**
***
* * * *.
Output
Output:-
Q8 Write a program in java to implement constructor using parameter.
Output:-
Q11 Write a
program to demonstrate the concept of abstract class with constructor
and ``final`` method.
Output
double getArea();
this.length = length;
this.width = width;
double radius;
Circle(double radius) {
this.radius = radius;
}
}
this.base = base;
this.height = height;
}
}
Output:-
Rectangle Area: 15.0
// File: Main.java
import mypackage.MyClass;
public class Main {
obj.displayMessage();
Output:-
Hello from MyClass in mypackage!
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.
ANS-
import java.util.*;
Output:-
Q19 Write a Java program to create a basic Java thread that
prints "Hello, World!" when executed
Output