JAVA Practical File
JAVA Practical File
FILE
CODE
RUN
CODE
Package 1
Package 2
RUN
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
of shape 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.
CODE
RUN
RUN
5. Write a program to implement stack. Use exception
handling to manage underflow and overflow
conditions.
CODE
RUN
6. Write a program that copies content of one file to
another. Pass the names of the files through
command-line arguments.
CODE
RUN
CODE
From file: p.txt
RUN
8. Write a program to create a frame using AWT.
Implement mouseClicked(), mouseEntered() and
mouseExited() events such that: a) Size of the
frame should be tripled when mouse enters it. b)
Frame should reduce to its original size when
mouse is clicked in it. c) Close the frame when
mouse exits it.
CODE
RUN
a)
b)
C)
9. Using AWT, write a program to display a string in
frame window with pink color as background.
CODE
RUN
CODE
RUN
11. Using AWT, write a program using appropriate
adapter class to display the message (“Typed character
is: <typedCharacter>") in the frame window when user
types any key.
CODE
RUN
12. Using AWT, write a program to create two buttons
labelled ‘A’ and ‘B’. When button ‘A’ is pressed, it
displays your personal information (Name, Course,
Roll No, College) and when button ‘B’ is pressed, it
displays your CGPA in previous semester
CODE
RUN
13. Rewrite all the above GUI programs using Swing
1.
CODE
RUN
2.
CODE
RUN
3.
CODE
RUN
4.
CODE
RUN
5.
CODE
RUN