Java Unit-4 Assignment Answers
Java Unit-4 Assignment Answers
Assignment Answers
Theory
2. Do not use the main method 2. Uses the main method for execution
3. Cannot run independently require API's (Ex. Web 3. Can run alone but require JRE.
API).
local computer.
5. The files cannot be read and write on the local 5. Applications are capable of performing
computer.
probably possible.
7. Applets cannot access files residing on the local 7. Can access any data or file available on the
computer. system.
8. Requires security for the system as they are 8. No security concerns are there.
untrusted.
Practical :
@Override
public void run() {
int sum = 0;
for (int i = start; i <= end; i++) {
sum += i;
}
thread1.start();
thread2.start();
try {
thread1.join();
thread2.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Task Completed");
}
}
// Draw a rectangle
g.drawRect(20, 40, 80, 40);
HTML FILE :
<html>
<body>
<applet code="DrawingApplet.class" width="200" height="200"></applet>
</body>
</html>
3. Write an applet that take 2 numbers as parameter and
display their average and sum.
Code :
import java.applet.Applet;
import java.awt.Graphics;
HTML FILE :
<html>
<body>
<applet code="AverageSumApplet.class" width="200" height="200">
<param name="num1" value="5">
<param name="num2" value="10">
</applet>
</body>
</html>