Professional Documents
Culture Documents
KRITIK BANSAL - 1802911018 - WT - Assignment - 1
KRITIK BANSAL - 1802911018 - WT - Assignment - 1
KRITIK BANSAL - 1802911018 - WT - Assignment - 1
KRITIK BANSAL
18202911018
CSI
Q.
Questions Marks BL
No.
1. Differentiate between applets and Java program application. 2 BL-4
ANS APPLETS: -
1. Applets are small Java programs that are designed to be included with the HTML
web document. They require a Java-enabled web browser for execution.
2. Applet does not require a main function for its execution.
3. Applets don’t have local disk and network access.
4. Applets can only access the browser specific services. They don’t have access to
the local system.
5. Applets cannot execute programs from the local machine.
6. An applet program is needed to perform small tasks or the part of it.
ANS When the Java program runs in a particular machine it is sent to java compiler,
which converts this code into intermediate code called bytecode. This bytecode is
sent to Java virtual machine (JVM) which resides in the RAM of any operating
system. Hence java is called platform independent language.
3. Write the java program to find addition of two numbers given from the 5 BL-4
keyboard. Using exception handling, display appropriate message if the input are
not valid numbers.
ANS package javaapplication3;
import java.util.InputMismatchException;
import java.util.Scanner;
4. Discuss the various categories of Packages. What is the importance of Packages? 5 BL-3
Also, show how packages are created and imported in Java.
Package in java can be categorized in two form, built-in package and user-
defined package.
There are many built-in packages such as java, lang, awt, javax, swing, net, io,
util, sql, rmi, nio, applet, text, security, time, math, net, beans, etc.
1) Java package is used to categorize the classes and interfaces so that they
can be easily maintained.
1. //save as Simple.java
2. package mypack;
3. public class Simple{
4. public static void main(String args[]){
5. System.out.println("Welcome to package");
6. }
7. }
You need to use fully qualified name e.g. mypack.Simple etc to run the
class.
1. Applet is initialized.
2. Applet is started.
3. Applet is painted.
4. Applet is stopped.
5. Applet is destroyed.
There are two standard ways in which you can run an applet:-
1.
2. 1. Executing the applet within a Java-compatible web browser.
3. 2. Using an applet viewer, such as the standard tool, applet-viewer.
An applet viewer executes your applet in a window. This is generally the fastest
and easiest way to test your applet.
4.