jarvis-1805 / JAVA-FILE

The file of JAVA of I year II semester

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JAVA-FILE

JAVA file for I Year II Semester.

Practical List

Question No. Question
Ques 1 Design a class Complex having a real part (x) and an imaginary part (y). Provide methods to perform the following on complex numbers:
a) Add two complex numbers.
b) Multiply two complex numbers.
c) toString() method to display complex numbers in the form: x + iy.
Ques 2 Create a class TwoDim which contains private members as x and y coordinates in package P1. Define the default constructor, a parameterized constructor and override toString() method to display the co-ordinates. Now reuse this class and in packageP2 createanother class ThreeDim, adding a new dimension as z as its private member. Define the constructors for the subclass and override toString() method in the subclass also. Write appropriate methods to show dynamic method dispatch. The main() function should be in a package P.
Ques 3 Define an abstract class Shape in package P1. Inherit two more classes: Rectangle in package P2 and Circle in package P3. Write a program to ask the user for the type ofshape and then using the concept of dynamic method dispatch, display the area of the appropriate subclass. Also write appropriate methods to read the data. The main() function should not be in any package.
Ques 4 Create an exception subclass UnderAge, which prints “Under Age” along with the age value when an object of UnderAgeclass is printed in the catch statement. Write a class exceptionDemo in which the method test() throws UnderAge exception if the variable age passed to it as argument is less than 18. Write main() method also to show working of the program.
Ques 5 Write a program to implement stack. Use exception handling to manage underflow and overflow conditions.
Ques 6 Write a program that copies content of one file to another. Pass the names of the files through command-line arguments.
Ques 7 Write a program to read a file and display only those lines that have the first two characters as '//' (Use try with resources).
Ques 8 Write a program to create a frameusing AWT. Implement mouseClicked(), mouseEntered() and mouseExited() eventssuch that:
a)Size of the frame should be tripled when mouse entersit.
b)Frame should reduce to its original size when mouse is clicked in it.
c)Close the frame when mouse exitsit.
Ques 9 Using AWT, write a program to display a string in frame window with pink color as background.
Ques 10 Using AWT, write a program to create two buttons named “Red” and “Blue”. When a button is pressed the background color should be set to the color named by the button’s label.
Ques 11 Using AWT, write a program which responds to KEY_TYPED event and updates the status window with message (“Typed character is: X”). Useadapter class for other two events.
Ques 12 Using AWT, write a program to create two buttons labelled ‘A’ and ‘B’. When button ‘A’ is pressed, it displays your personalinformation (Name, Course, Roll No, College) and when button ‘B’ is pressed, it displays your CGPA in previous semester.
Ques 13 Rewrite all the above GUIprograms using Swing.

Author

Shubhang Gupta
@shubhsahu1805

About

The file of JAVA of I year II semester

License:MIT License


Languages

Language:Java 100.0%