Page |1
RAJA BALWANT SINGH COLLEGE,
AGRA
Session 2019-20
Assignment
Of
Java Programming And
Dynamic Webpage Design
Submitted To:
Mr. Vivek Sir Submitted By:
Utkarsh Jindal
BCA 5th Sem.
Page |2
Acknowledgement
I would like to express my special thanks of
gratitude to my teacher Mr. VIVEK SIR who
gave me the golden opportunity to do this
wonderful project on the topic Java
Programming And Dynamic Webpage
Design, which also helped me in doing a lot of
Research and i came to know about so many new
things I am really thankful to them.
Secondly i would also like to thank my parents
and friends who helped me a lot in finalizing this
project within the limited time frame.
Page |3
INDEX
PROGRAM PAGE NO.
Addition of two no. 4
Demonstration of Wrapper Class 5
Demonstrate For Each Loop 6
Check a no. is prime or not 7
Demonstrate Anonymous Object 9
Show all type of Constructor 10
Demonstrate Static variable and static method 11
Demonstrate the use of this keyword 13
Demonstrate Inheritance 14
Demonstrate method Overloading 16
Demonstrate method Overriding 17
Demonstrate the use of super keyword 18
Show the use of abstract class 19
Show the use of interface 20
Show the use of package 21
Demonstrate Exception handling 22
Show the use of thread 23
Demonstrate list in HTML 24
Demonstrate frames in HTML 25
Demonstrate tables in HTML 26
Demonstrate Applet 28
Page |4
Program to addition of two numbers
import [Link];
class Add
public static void main(String args[])
int a, b;
[Link]("Enter two Number to calculate their sum");
Scanner in = new Scanner([Link]);
a = [Link]();
b = [Link]();
[Link]("Sum of the integers = " + (a+b));
Output:
Page |5
Program to demonstrate wrapper
class
public class WrapClass
public static void main(String args[])
int a=75;
//Example of Autoboxing
Integer i=[Link](a);
Integer j=a;
[Link](a+" "+i+" "+j);
Output:
Page |6
Program to demonstrate for each
loop
class ForEachLoop
public static void main(String[] args)
String[] Names = {"Amit", "Raju", "Sanjay", "Yash", "Utkarsh"};
for (String name : Names)
[Link](name);
Output:
Page |7
Program to check a no is prime or not
import [Link];
class PrimeNumber
public static void main(String[] args)
int temp;
boolean isPrime=true;
Scanner scan= new Scanner([Link]);
[Link]("Enter any number:");
int num=[Link]();
[Link]();
for(int i=2;i<=num/2;i++)
temp=num%i;
if(temp==0)
isPrime=false;
break;
if(isPrime)
[Link](num + " is a Prime Number");
Page |8
else
[Link](num + " is not a Prime Number");
Output:
Page |9
Program to Demonstrate anonymous object
class AnonymousObject {
public String add(int x, int y){
return "Addition is: " + (x+y);
public static void main(String[] args) {
[Link](new AnonymousObject().add(52,94));
Output:
P a g e | 10
Program to show all types of
Constructors
class ConstructorsExample
ConstructorsExample()
[Link]("Default or Non-Parameterized Constructor");
ConstructorsExample(float a, float b)
{
[Link]("Parameterized Constructor");
[Link]("Sum :"+(a+b));
}
public static void main(String[] args)
ConstructorsExample ce = new ConstructorsExample();
ConstructorsExample ce1 = new ConstructorsExample(13,85);
Output:
P a g e | 11
Program to demonstrate static
variable and static method
class Student
String name;
int rollNo;
static String ColgName;
static int counter = 0;
public Student(String name) {
[Link] = name;
[Link] = setRollNo();
static int setRollNo() {
counter++;
return counter;
static void setColg(String name){
ColgName = name ;
void getStudentInfo(){
[Link]("name : " + [Link]);
[Link]("rollNo : " + [Link]);
[Link]("ColgName : " + ColgName);
P a g e | 12
public class StaticExample
public static void main(String[] args)
[Link]("RBS");
Student s1 = new Student("Shivam");
Student s2 = new Student("Raja");
[Link]();
[Link]();
Output:
P a g e | 13
Program to demonstrate the use of
‘this’ keyword
class MyClass {
int example;
MyClass(int example){
[Link] = example;
public static void main(String[] args) {
MyClass obj = new MyClass(48);
[Link]("Value obj hold = " + [Link]);
Output:
P a g e | 14
Program to Demonstrate inheritance
class AClass
AClass()
[Link]("Class--A");
class BClass extends AClass
BClass()
[Link]("Class--B");
class CClass extends AClass
CClass()
[Link]("Class--C");
}
P a g e | 15
class Inheritance extends BClass
Inheritance()
[Link]("Inheritance");
public static void main(String args[]){
Inheritance obj = new Inheritance();
CClass obd1 = new CClass();
Output:
P a g e | 16
Program to demonstrate method
overloading
class Method
{
public void display(char c) {
[Link](c);
}
public void display(char c, int num) {
[Link](c + " "+num);
}
}
class Overloading
{
public static void main(String args[]) {
Method obj = new Method();
[Link]('U');
[Link]('J',10);
}
}Output:
P a g e | 17
Program to demonstrate method
overriding
class Human{
public void eat()
{
[Link]("Human is eating");
}
}
class Boy extends Human{
public void eat(){
[Link]("Boy is eating");
}
public static void main( String args[]) {
Boy obj = new Boy();
[Link]();
}
}
Output:
P a g e | 18
Program to demonstrate the use of
‘supper’ keyword
class AClass
{
AClass() {
[Link]("A is created");
}
}
class BClass extends AClass
{
BClass(){
super();
[Link]("B is created");
}
}
class SupperExample
{
public static void main(String args[]){
BClass obj = new BClass();
}
}
Output:
P a g e | 19
Program to show the use of abstract
class
abstract class Shape{
abstract void draw();
}
class Rectangle extends Shape{
void draw(){
[Link]("drawing rectangle");
}
}
class Circle1 extends Shape{
void draw(){
[Link]("drawing circle");
}
}
class Abstraction{
public static void main(String args[]){
Shape s=new Circle1();
[Link]();
}
}
Output:
P a g e | 20
Program to show the use of interface
interface Polygon {
void getArea(float length, float breadth);
class Rectangle implements Polygon {
public void getArea(float length, float breadth) {
[Link]("The area of the rectangle is " + (length * breadth));
class InterfaceExample {
public static void main(String[] args) {
Rectangle r1= new Rectangle();
[Link](7,4);
Output:
P a g e | 21
Program to show the use of package
package pack1;
public class PackageExmaple
public static void main(String args[])
[Link]("Welcome to class PackageExmaple in pack1");
Output:
P a g e | 22
Program to demonstrate exception
handling
import [Link].*;
public class ExcepExample {
public static void main(String args[]) {
try {
int a[] = new int[2];
[Link]("Access element three :" + a[3]);
catch (ArrayIndexOutOfBoundsException e) {
[Link]("Exception thrown :" + e);
[Link]("Out of the block");
Output:
P a g e | 23
Program to show the use of thread
class Thread2 implements Runnable
public void run()
[Link]("Thread is running...");
public static void main(String args[])
Thread2 t2=new Thread2();
Thread t =new Thread(t2);
[Link]();
Output:
P a g e | 24
Program to demonstrate lists in
HTML
<!DOCTYPE html>
<html>
<body>
<h2>Unordered List with Circle Bullets</h2>
<ul>
<li>Apple</li>
<li>Orange</li>
<li>Banana</li>
<li>Grapes</li>
</ul>
<h2>Ordered List with Numbers</h2>
<ol type="1">
<li>Car</li>
<li>Bike</li>
<li>Scooter</li>
</ol>
</body>
</html>
Output:
P a g e | 25
Program to demonstrate the use of
frames in HTML
<!DOCTYPE html>
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows = "40%,40%,40%">
<frame name = "top" src = "[Link]" />
<frame name = "main" src = "[Link]" />
<frame name = "bottom" src = "[Link]" />
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
Output:
P a g e | 26
Program to demonstrate the use of
tables in HTML
<!DOCTYPE html>
<html>
<head>
<title>HTML Table </title>
</head>
<body>
<table border = "1" width = "300" height = "200">
<tr>
<th>Roll No.</th>
<th>Name</th>
<th>Marks</th>
</tr>
<tr>
<td>101</td>
<td>Raman</td>
<td>76</td>
</tr>
<tr>
<td>102</td>
<td>Dhruv</td>
<td>61</td>
P a g e | 27
</tr>
<tr>
<td>103</td>
<td>Utkarsh</td>
<td>85</td>
</tr>
</table>
</body>
</html>
Output:
P a g e | 28
Program to demonstrate Applet
import [Link];
import [Link];
public class HelloWorld extends Applet
@Override
public void paint(Graphics g)
[Link]("Hello World", 20, 20);
//html file
<html>
<head>
<title>Applet Demo</title>
</head>
<body>
<applet code="[Link]" width="300" height="300">
</applet>
</body>
P a g e | 29
</html>
Output: