0% found this document useful (0 votes)
6 views14 pages

Chapter 1 Introduction to Java

Chapter 1 introduces Java as a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It covers Java's features, including its portability, security, and robustness, as well as its development environment and key packages. Additionally, it compares Java with C++, highlighting differences in platform independence, inheritance, and memory management.

Uploaded by

laita nikam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views14 pages

Chapter 1 Introduction to Java

Chapter 1 introduces Java as a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It covers Java's features, including its portability, security, and robustness, as well as its development environment and key packages. Additionally, it compares Java with C++, highlighting differences in platform independence, inheritance, and memory management.

Uploaded by

laita nikam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter 1 Introduction to java

What is Java
Java is a programming language and a platform. Java is a high level, robust,
object-oriented and secure programming language.
Java was developed by Sun Microsystems in the year 1995. James Gosling is
known as the father of Java. Before Java, its name was Oak. Since Oak was
already a registered company, so James Gosling and his team changed the Oak
name to Java.

Platform: Any hardware or software environment in which a program runs, is


known as a platform. Since Java has a runtime environment (JRE) and API, it is
called a platform.
Packages:- The classes are grouped together into related sets that are called packages.
Java Development kit(JDK) Includes hundred of packages. Some are commonly used in
java prog.

1. Language Support Package(Java. Lang):- Contains Classes to support the basic language features.

2. Input/output Package(java.i o):-Contains classes for data I/O operations.

3. Utility Package(java.util):-The package contains utility classes to provide utility Function such as date
and time function.
4. Swing Package(javax.swing):-These classes used for building graphical user
interface(GUI).

5. Abstract Window Toolkit Package(java.awt):-Classes in this package provide the original GUI
components.

Example:-Java.awt.gemo:-These classes define two Dimension geometric


shapes.

6. Java.awt.event:- The classes in this package are used in the implementation in your prog.

7. Applet Package(java.applet):-This includes set of classes that allows us to


create java applet

8. Networking Package(java.net):-Contains a classesFor communicating with


other computer via network
Feature of java :-
The primary objective of Java programming language creation was to make it portable, simple and secure
programming language. Apart from this, there are also some excellent features which play an important role in the
popularity of this language. The features of Java are also known as java buzzwords.
A list of most important features of Java language is given below.

1) Simple
2) Object-Oriented
3) Portable
4) Platform independent
5) Secured
6) Robust
7) Architecture neutral
8) Interpreted
9) High Performance
10) Multithreaded
11) Distributed
12) Dynamic
Simple
Java is simple and small languages. Manu features of C and C++ are not supported by java For example, Java does
not use pointers ,pre-proceesor header files(i.e#include),goto statement ,operator over loading is not done in java
programming.,multiple inheritance is not supported by java etc.
Familiarity is another striking features of java. Java uses many constructs of C and C++ and therefore java code
“looks like C++” Code. Java is a simplified version of C++.

Object-oriented
Java is an object-oriented programming language. Everything in Java is an object. Object-oriented means we organize
our software as a combination of different types of objects that incorporates both data and behavior.
Object-oriented programming (OOPs) is a methodology that simplifies software development and maintenance by
providing some rules.
Basic concepts of OOPs are:-Object,Class,Inheritance,Polymorphism,Abstraction,Encapsulation
Portable(Transferable)
Java ensure portability in two ways
1.Java compiler generates byte code instruction that can be implemented on any machine or any operating system
2.The size of primitive datatypes are machine independent.

Secured
While downloading any program on internet we must aware about the viruses or any illegal program that makes your
system unsafe. Java provides a firewall between a network application and your computer
When we use java compatible web browser we can safely download java applet or other program.

Robust
Robust simply means strong. Java is robust because:It uses strong memory management.There are exception handling
and the type checking mechanism in Java. Java restrict the user to find mistakes easily in program.Java is restrict
typed language it checkes code at run trime also and compile time also. All these points make Java robust.
Simply means of Robust are strong.
.
Platform Independent
Java is platform independent because it is different from other languages like C, C++, etc. which are compiled into
platform specific machines while Java is a write once, run anywhere language. A platform is the hardware or software
environment in which a program runs.
There are two types of platforms software-based and hardware-based. Java provides a software-based platform.
The Java platform differs from most other platforms in the sense that it is a software-based platform that runs on the
top of other hardware-based platforms.
Architecture-neutral
Java is architecture neutral because there are no implementation dependent features, for example, the size of primitive
types is fixed.
In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4 bytes of memory for 64-bit
architecture. However, it occupies 4 bytes of memory for both 32 and 64-bit architectures in Java.
Architecture represents processor.
A Language or Technology is said to be Architectural neutral which can run on any available processors in the real
world without considering their development and compilation
Interpreted:-Java is a two stage system i.e java uses both comiler as well as interpreter to execute its program
First java compiler translates source code(i.e.java files).into byte code instructions(i.e.class file). Bytes codes are not
machine instructions and therefore,in the second stage,Java interpreter generates machine code that can be directly
executed buy the machine that is running the java program.
High-Performance
Java is faster than other traditional interpreted programming languages because Java bytecode is "close" to native
code. It is still a little bit slower than a compiled language (e.g., C++). Java is an interpreted language that is why it is
slower than compiled languages, e.g., C, C++, etc.
It have high performance because of following reasons;
This language uses Bytecode which is faster than ordinary pointer code so Performance of this language is high.
Garbage collector, collect the unused memory space and improve the performance of the application.
It has no pointers so that using this language we can develop an application very easily.
It support multithreading, because of this time consuming process can be reduced to executing the program.

Distributed
Java is created for supporting distributed environment of the internet because it support various types of protocols
i.e. in networking distribured environment.
Multi-threaded
Multithreading means handling multiple task simultaneously. They process simultaneously in same memeory space.

Dynamic
Java is a dynamic language. It supports dynamic loading of classes. It means classes are loaded on demand. It also
supports functions from its native languages, i.e., C and C++.
Java supports dynamic compilation and automatic memory management (garbage collection).
It supports Dynamic memory allocation due to this memory wastage is reduce and improve performance of the
application.
The process of allocating the memory space to the input of the program at a run-time is known as dynamic memory
allocation, To programming to allocate memory space by dynamically we use an operator called 'new' 'new' operator
is known as dynamic memory allocation operator.

Java and Internet


Java can be use to create two types of program:-Application and Applets.
An application is a program that run on your computer under the operating system.
An Applet is an application designed to transmit over the internet and executed by the java web browser.
A Simple Java program
import java.io.*;
Public class program
{
public static void main(String args[])
{
System.out.println(“welcome”);
}}
1.The Keyword to public is called an access modifier. These control other part of a prog can use
this code.
2.The Keywords class to declare that new class is being define.
3. All thing in a java program must be inside a class.
Main Line
.Public static void main(string args[])
1.This is main()method at which prog will being executed. All java application prog begin by
Calling main().
2.It is declare static meaning that all object of this class share this one method.
3.The void keyword simply tells the compiler that main function does not return a value.
4. In main function there is only one parameter string args[],which declare parameter named args this is an
array object type string store sequence of class.
(*) means we import all the classes from the package.
JDK Environment:-
Java environment include a number of the development tools, class and method. The development tools are the parts
of the system knows as the Java Development Kit (JDK).
The class and method are parts of the Java Standard Library (JSL) also knows as the Application Programming
Interface (API).
The JDK comes with set of tools that are used for developing running java program. Following tools for JDK
1) Javavc :-
The java complier that translate human readable java source code architecture natural byte code which java interpreter
can understand .
2)Java:-
Java interpreter that’s runs applets and application interpreting bytes code files .It launches a java application by
starting java runtime environment ,loading a specified class and invoking that class’s main method to run the
program.
3)Applet Viewer:-
Enables us to run java applets. Normally applets are the program those can be embedded in a web page and run in
web browser. This is very useful tool which give the same effects but on console.
4)Java Doc:-
Create HTML format documentation from java source code file.
C++ vs Java
There are many differences and similarities between the C++ programming language and Java. A list of top differences between
C++ and Java are given below:
Comparison Index C++ Java
Platform-independent C++ is platform-dependent. Java is platform-independent.

Java is mainly used for application


C++ is mainly used for system programming. It is widely used in window,
Mainly used for
programming. web-based, enterprise and mobile
applications.

Java was designed and created as an


C++ was designed for systems and interpreter for printing systems but later
Design Goal applications programming. It was an extended as a support network computing. It
extension of C programming language. was designed with a goal of being easy to
use and accessible to a broader audience.

Goto C++ supports the goto statement. Java doesn't support the goto statement.
Java doesn't support multiple
Multiple inheritance C++ supports multiple inheritance. inheritance through class. It can be
achieved by interfaces in java.

Java doesn't support operator


Operator Overloading C++ supports operator overloading.
overloading.

Java supports pointer internally.


C++ supports pointers. You can write However, you can't write the pointer
Pointers
pointer program in C++. program in java. It means java has
restricted pointer support in java.

Java uses compiler and interpreter


C++ uses compiler only. C++ is both. Java source code is converted
compiled and run using the compiler into bytecode at compilation time. The
Compiler and Interpreter which converts source code into interpreter executes this bytecode at
machine code so, C++ is platform runtime and produces output. Java is
dependent. interpreted that is why it is platform
independent.

C++ supports both call by value and Java supports call by value only. There
Call by Value and Call by reference
call by reference. is no call by reference in java.
Java doesn't support structures and
Structure and Union C++ supports structures and unions.
unions.
C++ doesn't have built-in support for
Thread Support threads. It relies on third-party Java has built-in thread support.
libraries for thread support.

Java supports documentation


C++ doesn't support documentation
Documentation comment comment (/** ... */) to create
comment.
documentation for java source code.

Java has no virtual keyword. We can


C++ supports virtual keyword so
override all non-static methods by
Virtual Keyword that we can decide whether or not
default. In other words, non-static
override a function.
methods are virtual by default.

Java supports unsigned right shift


>>> operator that fills zero at the top
unsigned right shift >>> C++ doesn't support >>> operator. for the negative numbers. For
positive numbers, it works same like
>> operator.

You might also like