wd programs

11
Program 5 Q. Explain the Introduction, H istory and F eatures of Java. Differentiate between Java and javascript. Also give the steps to execute a program in Java. Ans. Javas History 1. Developed by Sun Microsystems (James Gosling) 2. A general-purpose object-oriented language 3. Oak - In1991 4. Java - In 1995 5. Hot Java – First Java Enabled Browser 6.  Netscape Navigator – In 1995 to incorporate Java Technology 7. Based on C/C++ 8. Designed for easy Web/Internet applications In the early 90s, extending the power of network computing to the activities of everyday life was a radical vision. In 1991, a small group of Sun engineers called the "Green Team" believed that the next wave in computing was the union of digital consumer devices and computers. Led by James Gosling, the team worked around the clock and created the programming language that would revolutionize our world – Java. The Gre en Tea m demons tra ted their new langua ge wit h an int erac tive, han dheld home-en ter tain ment con trolle r tha t was ori gin ally tar get ed at the dig ital cable television industry. Unfortunately, the concept was much too advanced for the them at the time. But it was just right for the Internet, which was just starting to take off. In 199 5, the tea m announ ced tha t the Net scap e Nav iga tor Int ernet bro wse r wou ld incorporate Java technology. Today, Java not only permeates the Internet, but also is the invisible force behind many of the applications and devices that power our day-to-day lives. From mobile  phones to handheld devices, games and navigation systems to e-business solutions, Java is everywhere! Features of Java Platf orm IndependentThe con cept of Wri te-o nce -run-a nywher e (known as the Platform independent) is one of the important key feature of java language that makes  java as the most powerful language. Not even a single language is idle to this feature  but java is more closer to this feature. The programs written on one platform can run

Upload: abhinav-singh

Post on 07-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 1/11

Program 5

Q. Explain the Introduction, History and Features of Java.Differentiate between Java and javascript. Also give the steps toexecute a program in Java.Ans.

Java ’s History

1. Developed by Sun Microsystems (James Gosling)2. A general-purpose object-oriented language3. Oak - In19914. Java - In 19955. Hot Java – First Java Enabled Browser 6. Netscape Navigator – In 1995 to incorporate Java Technology

7. Based on C/C++8. Designed for easy Web/Internet applications

In the early 90s, extending the power of network computing to the activities of everyday life was a radical vision. In 1991, a small group of Sun engineers called the"Green Team" believed that the next wave in computing was the union of digitalconsumer devices and computers. Led by James Gosling, the team worked around theclock and created the programming language that would revolutionize our world – Java.

The Green Team demonstrated their new language with an interactive, handheldhome-entertainment controller that was originally targeted at the digital cabletelevision industry. Unfortunately, the concept was much too advanced for the them atthe time. But it was just right for the Internet, which was just starting to take off. In1995, the team announced that the Netscape Navigator Internet browser wouldincorporate Java technology.

Today, Java not only permeates the Internet, but also is the invisible force behindmany of the applications and devices that power our day-to-day lives. From mobile

phones to handheld devices, games and navigation systems to e-business solutions,Java is everywhere!

Features of Java

Platform Independent The concept of Write-once-run-anywhere (known as the

Platform independent) is one of the important key feature of java language that makes

java as the most powerful language. Not even a single language is idle to this feature

but java is more closer to this feature. The programs written on one platform can run

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 2/11

on any platform provided the platform must have the JVM.

Simple

There are various features that makes the java as a simple language. Programs are

easy to write and debug because java does not use the pointers explicitly. It is much

harder to write the java programs that can crash the system but we can not say about

the other programming languages. Java provides the bug free system due to the strong

memory management. It also has the automatic memory allocation and deallocation

system.

Object Oriented

To be an Object Oriented language, any language must follow at least the four

characteristics.

• Inheritance : It is the process of creating the new classes and using the behavior of

the existing classes by extending them just to reuse the existing code and adding

the additional features as needed.

• Encapsulation: : It is the mechanism of combining the information and providing

the abstraction.

• Polymorphism: : As the name suggest one name multiple form, Polymorphism is

the way of providing the different functionality by the functions having the same

name based on the signatures of the methods.

• Dynamic binding : Sometimes we don't have the knowledge of objects about their

specific types while writing our code. It is the way of providing the maximum

functionality to a program about the specific type at runtime.

Robust

Java has the strong memory allocation and automatic garbage collection mechanism.

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 3/11

It provides the powerful exception handling and type checking mechanism as

compare to other programming languages. Compiler checks the program whether

there any error and interpreter checks any run time error and makes the system secure

from crash. All of the above features makes the java language robust.

Distributed

The widely used protocols like HTTP and FTP are developed in java. Internet

programmers can call functions on these protocols and can get access the files from

any remote machine on the internet rather than writing codes on their local system.

Portable

The feature Write-once-run-anywhere makes the java language portable provided

that the system must have interpreter for the JVM. Java also have the standard data

size irrespective of operating system or the processor. These features makes the java

as a portable language.

Dynamic

While executing the java program the user can get the required files dynamically from

a local drive or from a computer thousands of miles away from the user just by

connecting with the Internet.

Secure

Java does not use memory pointers explicitly. All the programs in java are run under

an area known as the sand box. Security manager determines the accessibility options

of a class like reading and writing a file to the local disk. Java uses the public key

encryption system to allow the java applications to transmit over the internet in the

secure encrypted form. The bytecode Verifier checks the classes after loading.

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 4/11

Performance

Java uses native code usage, and lightweight process called threads. In the beginning

interpretation of bytecode resulted the performance slow but the advance version of

JVM uses the adaptive and just in time compilation technique that improves the

performance.

Multithreaded

As we all know several features of Java like Secure, Robust, Portable, dynamic etc;you will be more delighted to know another feature of Java which is Multithreaded.Java is also a Multithreaded programming language. Multithreading means a single

program having different threads executing independently at the same time. Multiplethreads execute instructions according to the program code in a process or a program.Multithreading works the similar way as multiple processes run on one computer.

Difference between Java and Javascript

Java1. Java is object oriented language2. It is a compiled language3. Java is strong type language i.e. variables, data types must be declared4. Java was created by sun Microsystems5. Java can stand on its own (i.e standalone language)6. It follows static type checking 7. Java uses byte code8. Java is much larger and complicated language that creates standalone applications9. Difficult for common man to understand10. Creation of web pages takes longer time

Java script1. Java script is object based scripting language2. It is not compiled, it is interpreted3. Java Script is loose type language i.e. variables, data types may not be declared4. It was created by Netscape5. Java script must be placed inside the HTML documents6. It follows dynamic type checkingIt works directly therefore, no use of changing of byte code8. It is a text that is fed or encrypted into a browser 9. It is easier to understand10. It enables faster creation of web pages

Steps to execute a program in Java

To execute a program in java, just follow the following steps:

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 5/11

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 6/11

Q. WAP to print ‘Hello World’ in java.Ans.

class hello

{

public static void main(String args[])

{

System.out.println("Hello World");

}

}

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 7/11

Program 7

Q. WAP to print the pattern.

555554444333221

Ans.

public class pattern

{

public static void main(String args[])

{

for(int i=5;i>=1;i--)

{

for (int j=i;j>=1;j--)

{

System.out.print(i);

}

System.out.println(" ");

}

}

}

Program 8

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 8/11

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 9/11

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 10/11

8/4/2019 WD Programs

http://slidepdf.com/reader/full/wd-programs 11/11