java unit 5 print
java unit 5 print
Project Overview:
This project demonstrates a basic digital clock applet using Java. The applet displays the current time in
hours, minutes, and seconds, continuously updating in real-time.
Key Concepts:
Applets: Small Java programs that run within a web browser.
GUI Components: Basic graphical user interface elements like labels and fonts.
Event Handling: Handling events like timer ticks to update the clock display.
Threading: Using threads to perform tasks concurrently, ensuring smooth clock updates.
Project Structure:
1. Create a new Java class: Extend the Applet class and override the init() and paint() methods.
2. Initialize components: In init(), create a Label component to display the time and set its font and
color.
3. Implement the clock logic:
o Create a Thread to run the clock logic in the background.
o In the run() method of the thread:
Use Thread.sleep() to pause the thread for a second.
Get the current time using Calendar or Date class.
Format the time string (e.g., "HH:mm:ss").
Update the Label with the new time string.
Call repaint() to redraw the applet.
4. Display the clock: In paint(), draw the Label on the applet's canvas.
Code Snippet:
Java
repaint();
}
}
<html><head>
<title>Digital Clock Applet</title></head><body>
<applet code="DigitalClockApplet.class" width="200" height="50"></applet></body></html>
DESCRIPTIVE QUESTIONS
DEPARTMENT OF CSE
MID-II
SUB:oops SEM:
through java II-I
PART A PART B
Q.NO SET 1 2 3 4 5 6 7 TOTAL
S.NO
NO. a b c d e f g h i j CO3 CO4 CO5
MARKS 1 1 1 1 1 1 1 1 1 1 5 5 5 5 5 5 30
cos 4 4 4 4 5 5 5 5 3 3 4 4 5 5 3 3
1 237Y1A0554 4 1 1 1 1 1 1 1 1 1 1 5 5 5 3 28 83.33 100.00 28.57
2 237Y1A0555 1 0 2 3 3 2 10 41.67 35.71 0.00
3 237Y1A0556 2 1 1 1 1 1 1 1 5 5 1 3 21 41.67 100.00 14.29
4 237Y1A0557 3 1 1 1 1 1 1 1 1 5 5 3 5 26 83.33 100.00 14.29
5 237Y1A0558 4 1 1 1 1 1 1 1 1 1 1 5 4 4 23 50.00 92.86 28.57
6 237Y1A0559 1 1 1 1 1 1 3 3 4 15 41.67 64.29 7.14
7 237Y1A0560 2 1 1 1 1 1 1 3 3 2 4 18 58.33 64.29 14.29
8 237Y1A0561 3 1 1 1 1 1 1 1 1 1 1 5 5 5 5 30 100.00 100.00 28.57
9 237Y1A0562 4 1 1 1 1 1 1 1 1 1 1 5 5 5 5 30 58.33 100.00 64.29
10 237Y1A0563 1 1 1 0 1 1 1 1 1 1 1 5 5 3 22 83.33 57.14 28.57
11 237Y1A0564 2 1 1 1 1 1 5 5 4 4 23 0.00 92.86 71.43
12 237Y1A0565 3 1 1 1 1 1 1 1 3 3 5 3 21 83.33 57.14 21.43
13 237Y1A0566 4 1 1 1 1 1 1 1 1 1 1 5 4 4 4 27 50.00 64.29 85.71
14 237Y1A0567 1 1 1 1 1 4 4 5 17 83.33 42.86 7.14
15 237Y1A0568 2 1 1 1 1 1 1 1 4 5 4 4 24 33.33 92.86 50.00
16 237Y1A0569 3 1 1 1 1 1 1 3 3 1 3 16 41.67 64.29 14.29
17 237Y1A0570 4 1 1 1 1 1 1 1 1 1 1 5 5 5 5 30 58.33 100.00 64.29
18 237Y1A0571 3 1 1 1 4 3 10 0.00 50.00 21.43
19 237Y1A0572 2 1 1 1 1 1 1 1 1 1 1 5 5 5 5 30 16.67 100.00 100.00
20 237Y1A0573 3 1 1 1 1 1 1 1 1 1 2 2 4 2 19 16.67 57.14 64.29
21 237Y1A0574 4 1 1 1 1 1 5 5 5 4 24 41.67 85.71 50.00
22 237Y1A0575 1 1 1 1 1 1 1 1 1 4 4 16 50.00 28.57 42.86
23 237Y1A0576 2 1 1 1 1 1 1 3 9 8.33 50.00 7.14
24 237Y1A0577 3 1 1 1 3 3 9 0.00 35.71 28.57
25 237Y1A0578 4 1 1 1 1 4 5 5 5 23 100.00 71.43 7.14
26 237Y1A0579 1 1 1 1 1 1 1 1 5 4 5 5 26 91.67 64.29 42.86
27 237Y1A0580 2 1 1 1 2 3 1 1 10 16.67 42.86 14.29
28 237Y1A0581 3 1 1 1 1 1 1 1 1 1 1 5 5 3 23 16.67 100.00 50.00
29 237Y1A0582 4 3 2 4 3 12 25.00 35.71 28.57
30 237Y1A0583 1 1 1 0 1 0 1 1 1 1 1 4 2 3 5 22 58.33 50.00 57.14
31 237Y1A0584 2 1 1 1 1 1 1 1 2 4 3 16 41.67 71.43 7.14
32 237Y1A0585 3 1 1 1 1 1 1 1 1 4 4 3 5 24 58.33 50.00 71.43
33 237Y1A0586 4 1 1 1 1 1 4 3 3 15 58.33 14.29 42.86
34 237Y1A0587 1 1 1 1 1 1 1 1 1 1 1 5 4 4 4 27 83.33 64.29 57.14
35 237Y1A0588 2 1 1 1 1 1 1 1 1 5 5 5 3 26 33.33 100.00 57.14
36 237Y1A0589 3 1 1 1 1 0 1 1 1 4 4 5 4 24 91.67 78.57 14.29
37 237Y1A0590 4 1 1 1 1 1 1 1 1 1 5 5 4 23 50.00 100.00 21.43
38 237Y1A0591 1 1 1 1 1 1 1 1 1 5 5 5 4 27 50.00 57.14 92.86
39 237Y1A0592 2 1 1 1 1 1 4 4 4 17 41.67 14.29 71.43
40 237Y1A0593 3 1 1 1 1 1 1 1 1 1 1 4 5 5 5 29 100.00 28.57 92.86
41 237Y1A0594 4 1 1 1 1 1 1 1 1 1 1 5 5 5 4 29 91.67 100.00 28.57
42 237Y1A0595 1 1 1 1 1 1 1 1 1 1 5 5 3 22 83.33 57.14 28.57
43 237Y1A0596 2 1 1 1 1 2 1 7 8.33 42.86 0.00
44 237Y1A0597 3 1 1 1 1 1 1 4 4 3 3 20 66.67 78.57 7.14
45 237Y1A0598 4 1 1 1 1 1 1 4 2 2 14 50.00 50.00 7.14
46 237Y1A0599 1 1 1 1 1 1 1 1 1 2 5 5 4 24 50.00 71.43 57.14
47 237Y1A05A0 2 1 1 1 1 1 1 1 4 4 3 4 22 33.33 85.71 42.86
48 237Y1A05A1 3 0 1 1 1 1 1 1 1 1 1 2 4 3 4 22 75.00 35.71 57.14
49 237Y1A05A2 4 1 1 1 1 1 1 1 1 4 4 4 4 24 83.33 50.00 50.00
50 237Y1A05A3 1 1 1 1 1 1 1 3 3 12 41.67 42.86 7.14
51 237Y1A05A4 2 2 2 0.00 14.29 0.00
52 237Y1A05A5 3 1 1 1 1 1 1 5 3 4 18 41.67 78.57 14.29
53 237Y1A05A6 4 1 1 1 4 4 11 83.33 0.00 7.14
54 237Y1A05A7 1 1 1 1 1 1 1 1 1 1 1 2 3 4 19 50.00 64.29 28.57
55 247Y1A0512 2 1 1 1 1 1 1 1 1 5 5 5 23 58.33 92.86 21.43
56 247Y1A0513 3 1 1 1 1 1 1 1 1 1 1 2 4 16 50.00 28.57 42.86
57 247Y1A0514 4 1 1 1 1 1 1 1 1 1 5 5 5 4 28 91.67 92.86 28.57
58 247Y1A0515 1 1 1 1 1 1 1 1 1 4 4 4 2 22 25.00 78.57 57.14
59 247Y1A0516 2 1 1 1 1 1 1 5 5 5 3 24 83.33 21.43 78.57
60 247Y1A0517 3 1 1 1 1 1 1 1 1 1 1 4 5 5 5 29 100.00 57.14 64.29
61 247Y1A0518 4 1 1 1 1 1 1 1 1 1 4 4 2 4 23 50.00 78.57 42.86
62 247Y1A0519 1 1 1 1 1 1 1 1 1 1 1 5 5 5 5 30 58.33 100.00 64.29
63 247Y1A0520 2 1 1 1 1 1 1 1 1 1 1 5 5 5 25 58.33 100.00 28.57
DEPARTMENT OF CSE
MID I
SUB: OOPS SEM: II- A.Y:2023-24
THROUGH JAVA I
DEPARTMENT OF CSE
MID II
SUB:OOPS SEM: II-I A.Y:2023-24
THROUGH JAVA
S.NO Q.NO SET NO. PART A PART B TOTAL CO3 CO4 CO5
1 2 3 4 5 6 7
a B c d e f g h i j
MARKS 1 1 1 1 1 1 1 1 1 1 5 5 5 5 5 5 30
cos 4 4 4 4 5 5 5 5 3 3 4 4 5 5 3 3