Monday, December 7, 2009

check out some links in gilmapping

all the ways in news

http://www.gisdevelopment.net/news/viewn.asp?id=GIS:N_gnqbhzxlda&Ezine=dec0709&section=News

http://timesofindia.indiatimes.com/city/ludhiana/Digital-map-for-easier-navigation/articleshow/5289092.cms

http://epaper.hindustantimes.com//artMailDisp.aspx?article=24_11_2009_193_010&typ=1&pub=722

http://www.tribuneindia.com/2009/20091124/punjab.htm#13

http://docs.google.com/View?id=dwzsbzt_60hbsvsxp9

http://www.youtube.com/watch?v=KQHbqhPHK-o&feature=player_embedded

Monday, November 23, 2009

experience of the event "gillMapping"





The event "gillMapping" which was organized by Civil Department of guru nanak dev engineering college and Linux User Group(LUG), Ludhiana on 22 nov, 09.
well, the event started at 9:00am in the morning with the opening function in consultancy hall in GNE College, Ludhiana.
various dignitaries were present , many speeches were delivered on GPS Technology, OpenStreetMap and josm software.
I also present my views on the above mention software and also discuss the event with the present people.
after that we have refreshments from college. then we were brief about the event, usage and working of the gps. after that we move to gill village there we notify the various locations,places of interest, streets,roads and many other locations of gill village.
finally we came back to college and using josm software we edit the data and design the final map and uploaded on the openstreetmap.org.
following steps are taken for uploading the map.
1) receive the data from gps on pc by data cable.
2) grim software is needed for saving the gps file in .gpx format.
3) finally open the josm software open the .gpx file in josm then download the map from openstreet. then make amendments in the map and finally upload on the openstreetmap.
hence with the above mention steps your map will be uploaded on the INTERNET.

List of Members

NAME                  CLASS  GROUP
Daljeet Singh Pathania D3 IT L.U.G
Jagdeep Singh Malhi D3IT L.U.G
Aditi Arora D2CSE L.U.G
Akashdeep singh D4 CE A.C.E
Aman Shegal D4 CE A.C.E
Amanpreet Singh D2CSE L.U.G
Amrinder Singh D2IT L.U.G
Ankur Chauhan D2ECE L.U.G
Anurag Chaudry D2CSE L.U.G
biplamdeep singh A.C.E
Chandeep Singh D2CSE L.U.G
Davinder Kumar D2CSE L.U.G
Gurinder Singh D3 IT
Guriqbal Singh D2CSE L.U.G
Gurjyot Singh D2CSE L.U.G
Hargurdeep singh A.C.E
Harkaran singh D2 CE A.C.E
HarmanpreetSingh D1ECE L.U.G
Ismitpal singh D3CE A.V.S
Jaswinder singh D4 CE A.C.E
Mandeep Sngh D3IT
Mokshan abrol D4 CE A.C.E
Parveen Kumar D2IT L.U.G
Pranavanand D2CSE L.U.G
Priyanka Sharma D2IT L.U.G
Sandeep D2PE L.U.G
Shaina D2CSE L.U.G
Simarjeet singh D4 CE A.C.E
Sumit D2ECE L.U.G
Tanpreet singh D4 CE A.C.E
Vikas D2CSE L.U.G
Preeti Jaiin D4CE A.C.E
Gurmeher Singh D2CE

Sunday, November 22, 2009

the parposal of the event "gillmapping"

following is the proposal for the event "gillMapping" which was scheduled on 22nd nov,09.
I was assigned as a project leader for this event . the more detail and experience will be shortly added.


The Department of civil engineering,Guru Nank Dev engineering college,ludhiana is organinsing an event of “gillmapping” on 22/11/2009(Sunday) at 9:00 A.M. For preparing digital map of gill village with the help of nss unit,association of civil engineers &linux user group with following objectives.

(a)To help Govt./NGos for their social welfare schemes. (b)To help our community such as traffic police,cabs etc in track locating. (c)To help physically challenged people(blind) navigate on their own (d)To help grow industrial business in the area of “digital mapping” and to provide scope of placements for students.

We plan to start this project from gill village and thereafter the whole city will be covered. An inaugral function is being planned at Guru Nanak Dev Engineering College on 22/11/09 at 9:00A.M. To mark the start of this project and make everyone aware of it.

Open Street Maps

Open Free maps are Free editable maps.these are made with the help of GPS by anyone at anytime. These maps allows us to view,edit and use geographical data in the callobrative way from anywhere on the globe. Like in some areas, We have some buildings and street being built all the time and with the help of OSM we can always locate this location of sbeakers on the ground and can get up-to-date data.

More important thing is that information is free. It will be owned by the community- not by any big corporate which means it can be accesed by anyone,anytime and anywhere nad can also edit it accordingly. Open street map(OSM) maps are more accurate then anything else on the market in many parts of world depending upon awareness nad participation of community. By using OSM we will come up with new applications and winning innovations around the information we recorded.

Maps prepared by OSM have already Started In US and is new in India. These maps


(a)Help to Grow the industrial business in the area of digital mapping and provided the scope of placements of the students in the same area. (b)Help as track locator to the community such as Traffic Police,Cabs etc. (c)Help as a navigator for the physically challenged people(Blind).

Department of civil engineering at GNDEC Ludhiana is going to prepare such maps. Initially we are starting from Gill Village and Our target is to Prepare maps of ludhiana city. All the data collected by this will be given away free for others to use.

For collecting the data of Gill Village our Students will carry GPS to different part of gill village nad will record the information and then will upload and then this will be provided to the community for the use.

We can get further information regarding open street maps from below link http://news.bbc.co.uk/2hi/technology/8305924.stm http://wiki.openstreetmap.org/wiki

Faculty In charge:-

Er. Rajinder Ghai, Lecturer, Civil Engineering Department, Guru Nanak Dev Engineering College Ludhiana(Pb) India

Er. Harkamaljeet Singh Gill, Lecturer, Civil Engineering Department, Guru Nanak Dev Engineering College Ludhiana(Pb) India

Chairman : - Prof.(Dr.) H.S. Rai HOD,Department of Civil Engineering Guru Nanak Dev Engineering College Ludhiana(Pb) India



upcoming events:- uploading the list of the Mapping Team

posted by:-

Daljeet Singh Pathania

photos of linux events in genesis

Linux user group(LUG) events in College Genesis


In 20,Nov 2009 our college genesis is begin so Linux User Group (LUG ) conduct two events Workshop on FOSS & LINUX QUIZ . First off all our workshop is begin at 9.00am and Dr. H.S.Rai give Presentation on FOSS .

Introduction to FOSS:- FOSS is an open source software that is being used n linux operating system . A seminar on FOSS was held ,that was presented by Dr. Hardeep Singh Rai. He was presenting many effective information on open source software and systems specially on foss. According to them with the help of these open source softwares and system we can developed a new system that is according to our requirements and needs. Through , the help of the open source softwares we can develop our country in many assepts of information technology.

There was a open discussion on FOSS . Dr.Hardeep Singh Rai and Ajay Shiv Sharma was the in discussion . They were presented their views about these concepts that how to use these open source systems and modify them according to our needs. Also there was a questioner on FOSS and linux operating system. In this module there is question about open source system and the audience presented there was trying to answer these questions and also there was gift on behalf of these questions. We gain knowledge about these open source system a lot.

WORKSHOP ON DRUPAL:- Then, after the seminar on foss ,a workshop on drupal will conducted . In this workshop we work on Drupal (open soure) .Our lecturer Ajay Shiv Sharma was giving a lecture on this that how we work on drupal. He also giving information about DRUPAL which is also an open source software and we make a wonderful website by using drupal. In this module we install Drupal in our machines with some commands that are related to it .We follow the instructions of our lecturer and install it in our machines. Through drupal we develop websites which is very effective and it includes all the content that a website can have. We can learn how to make websites through there systems. There was group of some students that work according to the instructions of lecturer that can handle all this work .

Linux quiz:- At the end of this module of workshop, a quiz on linux and FOSS can de presented . In this quiz questions wiil be asked from the student who attend this whole module of linux. Many of students can participate in this quiz. Special prizes will be given to those students who win this quiz and also those students who work well in work shop any this community .


At end we are deeply thankful to our lecturers Ajay Shiv Sharma and Dr. Hardeep Singh Rai . With the help our teacher we succeeded in our goal of informing students about the open source system.

Monday, November 2, 2009

OSS CAMP in chandigarh


i have attended the oss camp in chandigarh on 24-oct-09, where oss stand for the open source services . It was Unconference on Open Source. this camp was basically promotion of the open source, and various products available in open service.
i have also given presentation on the linux operating system and also introduction LINUX USER GROUP (LUG) .

you can check it out link for oss community :-
http://osscamp.in

Thursday, August 20, 2009

report on core java for two months institutional training

the following report is submitted by me on 2months training:-

name= Daljeet singh pathania

class= pre-final year

branch=Information Technology

topic=core java

college= Guru Nanak Dev Engineering College, ludhiana(p.b)


DOEACC CENTERSRINAGAR/JAMMU

(FORMERLY CEDTI SRINAGAR/JAMMU)

DOEACC is an autonomous body of department of Information Technology, Ministry of Communication & Information Technology, Govt. of India.

DOEACC institute was established in 1983. There are 23 DOEACC institute in all over India. It is one of the most prestigious institutes in India, which offers various computer language courses, certification course, hardware courses and many more in the field of computers.

HISTORY OF JAVA

Java was conceived by james gosling, Patrick Naughton, Chris Warth, Ed Frank and Mike Sheridan at Sun Microsystems, Inc. in 1991.It took 18 months to develop the first working version. This language was initially called “OAK,” but was renamed “java” in 1995.The original impetus for java was not the Internet! Instead, the primary motivation was the need for a platform independent language that could be used to create software to be embedded in various consumer electronic devices.thi s effort ultimately led to creation of java. The emergence of the World Wide Web, java was propelled to the forefront of the computer language design, because the Web too demanded portable programs.

INTRODUCTION TO JAVA

To fully understand java, one must understand the reasons behind its creation, the forces that shaped it, and legacy that it inherits. Like the successful computer language that came before, java is blend of the best elements of its rich heritage combined with the innovative concepts required by its unique mission. Much of the character of the java is inherited from C and C++.From C, java derives its syntax. Many of java’s OOPs features were influenced by C++. Creation of java was deeply rooted in the process of refinement and adaptation that has been occurring in computer programming language for the past several decades.

FEATURES OF JAVA

JAVA APPLETS

An applet is a special kind of java program that is designed to be transmitted over the Internet and automatically executed by a java-compatible web browser. Furthermore, an applet is downloaded on the demand, without further interaction with user. If the user click a link that contain the applet, the applet will automatically downloaded and run in the browser. The creation of the applet changed Internet programming because it expanded the universe of objects that can move about freely in the cyberspace.

Java’s Magic: The Bytecode

The output of the java compiler is not the executable code Rather, it is bytecode. Bytecode is a highly optimized set of instructions designed to be executed by the java run time system, which is called the Java Virtual Machine(JVM). Translating a java program into the bytecode makes it much easier to run a program in a wide variety of environments because only the JVM needs to be implemented for each platform. Although the details of the JVM will differ from platform to platform, all understand the same bytecode.

Servlets: java on the server side

A servlet is a small program that executes on the server. A servlet is a small program that executes on the server. Just as applets dynamically extend the functionality of a web browsers, servlets dynamically extend the functionality of a web server. Thus, with the advent of the servlet, Java spanned both sides of the client/server connection. Servlent are used to create dynamically generated content that is then served to the client. The servlent offers several advantages, including increased performance. Because servlents(like all Java programs) are compiled into bytecode and executed by the JVM, they are highly portable.

Instead of above main features there are several other important features are as following:-

· Simple

· Secure

· Portable

· Object-oriented

· Robust

· Multithreaded

· Architecture-neutral

· Interpreted

· High performance

· Distributed

· Dynamic

The Evolution of java

The initial release of java was nothing short of revolutionary, but it did not mark the end of java’s era of rapid innovation. The java 1.0 was the first release of java. Soon after the release of Java 1.0, the designers of Java had already created Java 1.1.The next major release of Java was Java 2. Where the “2”indicates “second generation.” The creation of Java 2 was watershed event, marking the beginning of Java’s “modern age.” The first release of Java 2 carried the version number 1.2.

Java 2 added support for a number of new features, such as Swing and the Collections Framework, and it enhanced the Java Virtual Machine and various programming tools.

J2SE 1.3 was the first major upgrade to the original Java 2 release. For the most part, it added to existing functionality and “tightened up” the development environment.

The release of J2SE 1.4 further enhanced Java. The release contained several important upgrades, enhancements, and additions. For example, it added the new keyword assert.

The next release of Java was J2SE 5, and it was revolutionary. J2SE 5 fundamentally expanded the scope, power and range of language.

· Generics

· Annotations

· Autoboxing and auto-unboxing

· Enumerations

· Enhanced, for-each style for loop

· Variable-length arguments (varargs)

· Static import

· Formatted I/O

· Concurrency utilities

JAVA SE 6

The newest release of Java is called Java SE 6. With the release of Java SE 6, Sun once again decided to change the name of Java platform. First, notice that the “2” has been dropped. Thus, the platform now has the name Java SE, and the official product name is Java Platform, Standard Edition 6. As with J2SE5, the 6 in the Java SE 6 is the product version number is 1.6.

1# :-> Write a program to illustrate the use of various Data Types of java.

class chap3basics {

public static void main(String[] args)

{

int lightspeed;

long days;

long seconds;

long distance;

lightspeed =186000;

days=1000;

seconds= days*24*60*60;

distance=lightspeed*seconds;

System.out .println("in"+ days+"days light will travel

about"+distance +"miles.");

char ch1,ch2;

ch1=88;

ch2='y';

System.out .println("ch1 $ch2"+ch1+" "+ch2);

ch1++;

System.out .println(ch1);

}

}

The output of the above program is as follows:-

In1000days light will travel about1607040000000miles.

Ch1 $ch2X y

Y

2# :-> Write a program to illustrate the use of boolean Type of java.

class chap3booltest {

public static void main(String[]args)

{

boolean b;

b=false;

System.out.println("b is" +b);

b=true;

System.out .println("b is "+b);

if(b)

System.out .println("this is executed coz b is true");

b= false;

if(b)

System.out .println("this will not executed coz b is false");

System.out .println("10>9"+(10>9));

System.out .println("9>10"+(9>10));

}

}

The out put of the above program is as follow:-

b is false

b is true

this is executed coz b is true

10>9true

9>10false

3# :-> Write a program to illustrate some type conversion that required casts.

class chap3conversion{

public static void main(String[]args){

byte b;

int i=257;

double d=323.134;

{System.out.println("int to byte");

b=(byte) i;

System.out.println("i $ b"+i+" "+b);

System.out.println("double to int");

i= (int) d;

System.out.println("d $ i"+d+" "+i);

System.out.println("double to byte");

b= (byte)d;

System.out.println("d $ b"+d+" "+b);

}

} }

The output of the above program is as follow:-

int to byte

i $ b 257 1

double to int

d $ I 323.134 323

double to byte

d $ b 323.134 67

4# :-> Write a program to illustrate a two-dimensional array in java.

class chap3twodarray{

public static void main(String[]args){

int twodarray[] []=new int[7][7];

int i,j,k=0,l;

for(i=0;i<6;i++)

for(j=0;j<4;j++){

twodarray[i] [j]=k;

k++;}

for(i=0;i<6;i++){

for(j=0;j<4;j++)

System.out.print(twodarray[i] [j]+ "\t ");

System.out.println();

}

}

}

The output of the above program is as follow:-

0 1 2 3

4 5 6 7

8 9 10 11

12 13 14 15

16 17 18 19

20 21 22 23

5# :-> Write a program to illustrate the bitwise logical operators.

class chap4bitlogic {

public static void main(String[] args){

String binary[]={"0000" ,"0001","0010","0011","0100","0101","0110","0111","1000",

"1001","1010","1011","1100","1101","1110","1111"};

int a=3, b=6; /** here the values of a and b are not taken from string*/

int c=a|b;

int d=a &b;

int e=a^b;

int f=(~a&b) | (a & ~b);

int g=~a &0x0f;

System.out.println("a="+"\t"+binary[a]);

System.out.println("b="+"\t"+binary[b]);

System.out.println("c="+"\t"+binary[c]);

System.out.println("d="+"\t"+binary[d]);

System.out.println("e="+"\t"+binary[e]);

System.out.println("f="+"\t"+binary[f]);

System.out.println("g="+"\t"+binary[g]);

}

}

The output of the above program is as follows:-

a= 0011

b= 0110

c= 0111

d= 0010

e= 0101

f= 0101

g= 1100

6# :-> Write a program to illustrate the switch statement.

class ch5sampleswitch{

public static void main(String[]args) {

for(int i=0;i<6;i++)

switch(i) {

case 0:

System.out.println("i is=" + i);

break;

case 1:

System.out.println("i is=" + i);

break;

case 2:

System.out.println("i is=" + i);

break;

case 3:

System.out.println("i is=" + i);

break;

default:

System.out.println("i is greater then 3" );

} }

The output of the above program is as follows:-

i is=0

i is=1

i is=2

i is=3

i is greater then 3

i is greater then 3

7# :-> Write a program to illustrate the for-each style for loop in java.

class ch5foreach {

public static void main(String args[] ) {

int num[] = {1,2,3,4,5,6,7,8,9,10 };

int sum=0;

for (int x : num) {

System.out.println("value is="+x);

sum += x;

if(x==5) break;

x= x*10; // this statement will not have any effect on for-each statement

}

System.out.println("summation:"+sum);

}

}

}

The output of the above program is as follows:-

Value is=1

Value is=2

Value is=3

Value is=4

Value is=5

Summation:15

8# :-> Write a program to illustrate the concept of classes with the help of constructor.

class box {

double width;

double height;

double depth;

box() {

width=height=depth=10;

}

box(double w,double h,double d)

{this.width=w;

height=h;

depth=d;

}

double vol(){

return width*height*depth;

}

}

class ch6boxdemo6 {

public static void main(String[] args) {

box mybox=new box(5,6,4);

box mybox2=new box();

System.out.println("the vol is " +mybox.vol());

System.out.println("the vol is " +mybox2.vol());

}

}

The output of the above program is as follows:-

The vol is 120.0

The vol is 1000.0

9# :-> Write a program to illustrate static variables, methods and blocks in java.

class ch7usestatic {

static int a = 3;

static int b;

static void meth(int x){

System.out.println("x=" +x);

System.out.println("a=" +a);

System.out.println("b=" +b);

}

static {

System.out.println("static block initilized" );

b=a*4;

}

public static void main(String[] args) {

meth(42);

}

}

The output of the above program is as follows:-

Static block initialized

X=42

a=3

b=12

10# :-> Write a program to illustrate the variable-length arguments.

class ch7varargs2 {

static void vatest(String msg, int ... v) {

System.out.print(msg+ v.length +"contents:");

for(int x: v)

System.out.print(x+" ");

System.out.println();

}

public static void main(String args[])

{

vatest("one varargs:",10);

vatest("three varargs:",1,2,3);

vatest("no varargs");

}

}

The output of the above program is as follow:-

one vararges :1contents :10

three varargs :3contents :1 2 3

no varargs 0contents:

11# :-> Write a program to illustrate the concept of inheritance using super in java.

class box{

private double width,height,depth;

box(box ob) {

width=ob.width;

height=ob.height;

depth=ob.depth;

}

box(double w,double h,double d) {

width =w;

height=h;

depth=d;

}

box() {

width = -1;

height=-1;

depth=-1;

}

box(double len) {

width=height=depth=len;

}

double volume() {

return width*height*depth;

}

}

class boxweight extends box {

double weight;

boxweight(double w,double h,double d, double m)

{super(w,h,d);

weight =m;

}

boxweight(double h,double m)

{super(h);

weight =m;

}

boxweight()

{super();

weight =-1;

}

boxweight(boxweight ob)

{super(ob);

weight =ob.weight;

}

}

class ch8demoboxweight {

public static void main(String[]args) {

boxweight ob1=new boxweight(10,12,14,19);

boxweight ob2=new boxweight(1,2,3,4);

boxweight ob3=new boxweight();

boxweight ob4=new boxweight(3,4);

boxweight ob5=new boxweight(ob2);

box boxob=new box(4);

double vol;

vol=boxob.volume();

System.out.println(" \nthe volume is:" +vol);

vol=ob1.volume();

System.out.println("\n the volume is:" +vol);

System.out.println(" \nthe weight is:" +ob1.weight);

vol=ob2.volume();

System.out.println("\n the volume is:" +vol);

System.out.println();

boxob=ob2;//a refrence variable of SUPER class can be //assigned a refrence to any SUB class

vol=boxob.volume();

System.out.println(" the volume is:" +vol);

vol=ob3.volume();

System.out.println("\n the volume is:" +vol);

vol=ob4.volume();

System.out.println("\n the volume is:" +vol);

vol=ob5.volume();

System.out.println("\n the volume is:" +vol);

}

}

The output to the above program is as follows:-

the volume is:64.0

the volume is:1680.0

the weight is:19.0

the volume is:6.0

the volume is:6.0

the volume is: -1.0

the volume is:27.0

the volume is:6.0

12# :-> Write a program to illustrate the concept of

Overriding in java.

//method overrriding.

class A {

int i,j;

A (int a, int b) {

i=a;

j=b;

}

//display i and j

void show() {

System.out.println("i and j"+i +j);

}

}

class B extends A{

int k;

B(int a,int b,int c) {

super(a,b);

k=c;

}

// display k-this overrides show() in A

void show() {

System.out.println("k ="+" "+k);

}

}

class ch8override {

public static void main(String[] args) {

B subob =new B(1,2,3);

subob.show();

}

}

The output of the above program is as follows :-

K = 3

13# :-> Write a program to illustrate the concept of

packages in java.

package mypack;

class balance {

String name;

double bal;

balance(String n, double b) {

name =n;

bal =b;

}

void show() {

if(bal<0)

System.out.print("---> ");

System.out.println(name +":$"+bal);

} }

class ch9accountbalance {

public static void main(String args[]) {

balance current[] =new balance[3];

current[0] =new balance("k.j.fielding", 123.23);

current[1] =new balance("will tell", 157.02);

current[2] =new balance("tom jackson", -12.33);

for(int i=0;i<3;i++)

current[i].show();

} }

The output of the above program is as follows:-

k.j.fielding:$123.23

will tell:$157.02

---> tom Jackson:$-12.33

14# :-> Write a program to illustrate the concept of

interfaces in java.

interface callback {

void callback(int param);

}

class client implements callback{

//implements callback interface

public void callback(int p) {

System.out.println("callback called with " +p);

}

}

class ch9testface {

public static void main(String args[]) {

callback c=new client();

c.callback(42);

}

}

The output of the above program is as follow:-

Callback called with 42

15# :-> Write a program to illustrate the concept of

Exception handling in java.

class ch10exc2 {

public static void main(String args[]) {

int d,a;

try{

d=0;

a=42/d;

System.out.println("this will not be printed.");

}

catch(ArithmeticException e) {

System.out.println("division by zero.");

}

System.out.println("after catch statement.");

}

}

The output of the above program is as follows :-

division by zero.

After catch statement.

16# :-> Write a program to illustrate the concept of

Exception handling by using throw keyword in java.

class ch10throwdemo {

static void demoproc() {

try {

throw new NullPointerException("demo");

}

catch(NullPointerException e) {

System.out.println("caught inside demoproc.");

throw e;

}

}

public static void main(String args[]) {

try {

demoproc();

}

catch(NullPointerException e) {

System.out.println("Recaught: "+e);

}

}

}

The output of the above program is as follow :-

Caught inside demoproc.

Recaught: java.lang.NullPointerException: demo

17# :-> Write a program to illustrate the concept of

Multiple threads in java.

//Create multiple threads.

class NewThread implements Runnable {

String name; // name of thread

Thread t ;

NewThread(String threadname) {

name = threadname;

t = new Thread(this, name) ;

System.out.println("New thread: "+ t) ;

t.start () ; // Start the thread

}

// This is the entry point for thread.

public void run () {

try {

for(int i = 5; i > 0; i--) {

System.out. println(name + ": " + i) ;

Thread.sleep(1000) ;

}

} catch (InterruptedException e) {

System.out.println(name + " Interrupted");

}

System.out.println(name + " exiting.");

}

}

class MultiThreadDemo {

public static void main (String args [ ] ) {

new NewThread ("One") ; // start threads

new NewThread ("Two") ;

new NewThread ("Three") ;

try {

// wait for other threads to end

Thread.sleep(10000) ;

} catch (InterruptedException e) {

System.out.println("Main thread Interrupted") ;

}

System.out.println("Main thread exiting.");

}

}

The output from this program is shown here:

New thread: Thread[One, 5,main]

New thread: Thread[Two,5,main]

New thread: Thread[Three,5,main]

One: 5

Two: 5

Three: 5

One: 4

Two: 4

Three: 4

One: 3

Three: 3

Two: 3

One: 2

Three: 2

Two: 2

One: 1

Three: 1

Two: 1

One exiting.

Two exiting.

Three exiting.

Main thread exiting.

18# :-> Write a program to illustrate the concept of enumerated data type in java.

// An enumeration of apple varieties.

enum Apple {

Jonathan, GoldenDel, RedDel, Winesap, Cortland

}

class EnumDemo {

public static void main(String args[ ])

{

Apple ap;

ap= Apple.RedDel;

// Output an enum value.

System.out.println("Value of ap: " + ap);

System.out.println();

ap = Apple.GoldenDel;

// Compare two enum values.

if(ap ==Apple.GoldenDel)

System.out.println("ap contains GoldenDel. \n");

// Use an enum to control a switch statement.

switch(ap) {

case Jonathan:

System.out.println("Jonathan is red .");

break;

case GoldenDel:

System.out.println("Golden Delicious is yellow.");

break;

case RedDel:

System.out.println("Red Delicious is red.");

break;

case Winesap:

System.out.println("Winesap is red.");

break;

case Cortland:

System.out.println("Cortland is red.");

break;

}

}

}

The output of the above program is as follows:-

Value of ap: RedDel

ap contains GoldenDel.

Golden Delicious is yellow.

19# :-> Write a program to illustrate the concept of applet in java.

import java.awt.*;

import java.applet.*;

/*

*/

public class SimpleApplet extends Applet {

public void paint(Graphics g) {

g.drawString(" A Simple Applet" , 200, 20);

}

}

To run the above code a html code is also required which is as follows:-

After running the above to codes the applet run in the window produced by SimpleApplet. The following is the content of the applet.

A Simple Applet

20# :-> Write a program to illustrate the concept of

Generics in java.

//A simple genric class

//here, t is a type parameter that

//will be replace by a real type

// when an object of type gen is created.

class Gen {

T ob; // declare an object of type T

// pass the constructor a reference to an object of type T

Gen(T o) {

ob=o;

}

//return ob.

T getob() {

return ob;

}

// show type of T.

void showtype() {

System.out.println("Type of T is " + ob.getClass().getName());

}

}

class ch14gendemo {

public static void main( String[] args) {

// create a Gen reference for the integers.

Gen iob;

/* create s Gen object and assign its reference

to iob. notice the use of autoboxing to encapsulate the value

88 within an Integer object.

*/

iob= new Gen(88);

// show the type of data used by iob.

iob.showtype();

//get the value in iob.Notice that no cast is needed

int v=iob.getob();

System.out.println("value:" +v);

System.out.println();

// create a Gen object for strings.

Gen strob = new Gen("Generics Test");

// show te type of data used by strob.

strob.showtype();

// get the value of strob.Again, notice that no cast is neede.

String str =strob.getob();

System.out.println("value: "+ str);

}

}

The output of the above program is as follows:-

Type of T is java.lang.Integer

Value:88

Type of T is java.Lang.String

Value: Generics Test