_________________________________________________________________________________
Prepared By : Uday Shah (HOD-IT)
Contact No : 7600044051
E-Mail : rupareleducation@gmail.com
1)
History of Java ?
·
Java is a
platform-independent programming language used to create secure and robust
application that may run on a single computer or may be distributed among
servers and clients over a network.
·
Java features such as
platform-independency and portability ensure that while developing Java EE
enterprise applications, you do not face the problems related to hardware ,
network , and the operating system.
·
Java was started as a
project called "Oak" by James Gosling in June 1991. Gosling's goals
were to implement a virtual machine and a language that had a familiar C like
notation but with greater uniformity and simplicity than C/C++.
·
The First publication of
Java 1.0 was released by Sun Microsystems in 1995. It made the promise of
"Write Once, Run Anywhere", with free runtimes on popular platforms.
·
In 2006-2007 Sun released
java as open source and and plateform independent software.
·
Over time new enhanced
versions of Java have been released. The current version of Java is Java 1.7
which is also known as Java 7.
2)
Features of Java ? Characteristics of Java ?
The characteristics and features of java are as follows.
1) Simple
·
Java is a simple language
because of its various features, Java Doesn’t Support Pointers , Operator
Overloading etc. It doesn’t require unreferenced object because java support
automatic garbage collection. Java provides bug free system due to the strong
memory management.
2) Object-Oriented
·
Object-Oriented Programming
Language (OOPs) is the methodology which provide software development and
maintenance by using object state, behavior , and properties. Object Oriented
Programming Language must have the following characteristics.
o
Encapsulation
o
Polymorphism
o
Inheritance
o
Abstraction
·
As the languages like
Objective C, C++ fulfills the above four characteristics yet they are not fully
object oriented languages because they are structured as well as object
oriented languages.In java everything is an Object. Java can be easily extended
since it is based on the Object model
3) Secure
·
Java is Secure Language
because of its many features it enables to develop virus-free, tamper-free
systems. Authentication techniques are based on public-key encryption. Java
does not support pointer explicitly for the memory. All Program Run under the
sandbox.
4) Robust
·
Java was created as a
strongly typed language. Data type issues and problems are resolved at
compile-time, and implicit casts of a variable from one type to another are not
allowed.
·
Memory management has been
simplified java in two ways. First Java does not support direct pointer
manipulation or arithmetic. This makes it possible for a java program to
overwrite memory or corrupt data.
·
Second , Java uses runtime
garbage collection instead of freeing of memory. In languages like
c++, it Is necessary to delete or free memory once the program has finished
with it.
5) Platform-independent.
·
Java Language is
platform-independent due to its hardware and software environment. Java code
can be run on multiple platforms e.g. windows, Linux, sun Solaris, Mac/Os etc.
Java code is compiled by the compiler and converted into byte code. This byte
code is a platform independent code because it can be run on multiple platforms
i.e. Write Once and Run Anywhere(WORA).
6) Architecture neutral
·
It is not easy to write an
application that can be used on Windows , UNIX and a Macintosh. And its getting
more complicated with the move of windows to non Intel CPU architectures.
·
Java takes a different
approach. Because the Java compiler creates byte code instructions that are
subsequently interpreted by the java interpreter, architecture neutrality is
achieved in the implementation of the java interpreter for each new
architecture.
7) Portable
·
Java code is portable. It
was an important design goal of Java that it be portable so that as new
architectures (due to hardware, operating system, or both) are developed, the
java environment could be ported to them.
·
In java, all primitive
types(integers, longs, floats, doubles, and so on) are of defined sizes, regardless
of the machine or operating system on which the program is run. This is in
direct contrast to languages like C and C++ that leave the sized of primitive
types up to the compiler and developer.
·
Additionally, Java is
portable because the compiler itself is written in Java.
8) Dynamic
·
Because it is interpreted ,
Java is an extremely dynamic language, At runtime, the java environment can
extends itself by linking in classes that may be located on remote servers on a
network(for example, the internet)
·
At runtime, the java
interpreter performs name resolution while linking in the necessary classes.
The Java interpreter is also responsible for determining the placement of
object in memory. These two features of the Java interpreter solve the problem
of changing the definition of a class used by other classes.
9) Interpreted
·
We all know that Java is an
interpreted language as well. With an interpreted language such as Java,
programs run directly from the source code.
·
The interpreter program
reads the source code and translates it on the fly into computations. Thus,
Java as an interpreted language depends on an interpreter program.
·
The versatility of being
platform independent makes Java to outshine from other languages. The source
code to be written and distributed is platform independent.
·
Another advantage of Java
as an interpreted language is its error debugging quality. Due to this any
error occurring in the program gets traced. This is how it is different to work
with Java.
10) High performance
·
For all but the simplest or
most infrequently used applications, performance is always a consideration for
most applications, including graphics-intensive ones such as are commonly found
on the world wide web, the performance of java is more than adequate.
11) Multithreaded
·
Writing a computer program
that only does a single thing at a time is an artificial constraint that we have
lived with in most programming languages. With java, we no longer have to live
with this limitation. Support for multiple, synchronized threads is built
directly into the Java language and runtime environment.
·
Synchronized threads are
extremely useful in creating distributed, network-aware applications. Such as
application may be communicating with a remote server in one thread while
interacting with a user in a different thread.
12) Distributed.
·
Java facilitates the
building of distributed application by a collection of classes for use in
networked applications. By using java’s URL (Uniform Resource Locator) class,
an application can easily access a remote server. Classes also are provided for
establishing socket-level connections.
Question 3:: Java
edition
·
Java is a platform
independent language it support multi threaded and Secure programming Java
Technology is both programming language and platform Java programming language
is high level object oriented programming there are several platform supported
by the Java that is
·
Java Platform
standard edition
·
Java Platform
Enterprise edition
·
Java Platform micro
edition
·
All job platform
consists of the Java Virtual Machine and application programming interface
1. Java Platform
standard edition
Java edition provide core functionality of
Java programming language define everything from the basic type and the object
of Java programming language to high-level flowers that are used for the
networking security database access to UI development XML parsing etc.
2. Java Platform
Enterprise edition
Java Enterprise
edition platform is built on top of the Java 2nd edition platform
Java Enterprise edition platform provide an
API and Runtime environment for developing and running a large scale
multithreaded scalable reliable and Secure network application.
3. Java platform micro edition
Jamaica audition
pattern provide an API and small footprint virtual machine for running a Java
programming language application on the small device like mobile device.
Question 4: JDK JVM and JRE
·
JDK and its
component
·
JDK means Java
development kit which provide the collections of tools that are used to develop
and run Java program following the list of the JDK component
·
Applet viewer it in
able to run Java applet programming
·
javac is java
compiler which translates Java source code to bytecode file using interpreter
·
Java it is a Java
interpreter which run application by reading and interpreting bytecode file
·
Java divorcee it
create HTML format document from Java source code file
·
Java is it reduce
header file from use with native methods
·
As a java debugger
which help one to find error in program
JVM Java Virtual Machine
·
JVM means Java
Virtual Machine all languages compiler translate source code into the machine
code from a specific purpose in a computer Java compiler also does the same
thing
·
Rock company
produce intermediate code known as byte code for machine to read instructions
and machine is call JVM
·
Which is exist only
inside the Computer memory following is a diagram that represent the process of
JVM
·
According to above
diagram the virtual machine code is not a machine specific the machine specific
code is generated by the Java interpreter by act as mediator between the
virtual machine and the real machine following is a diagram that represent the
process of converting the bytecode into the machine code
JRE Java Runtime environment
·
JRE means
java-runtime-environment.
·
It is set of
software tools for development Java application it compile with the Java
Virtual Machine platform core class and supporting libraries there is a part of
the JDK but can be downloaded separately.
·
Java language is a
programming language similar to the C language however since it is a new
language it is not natively supported by all operating system there for the
Java Runtime environment.
· May need to be
install your compare computer for Java applet and JAVA application to run.
Question 5 :: JDK tools
In Java language
two types of programming mainly used that maybe application or Apple 8 JDK
tools can be categorised under the different category like
·
Basic tools
·
RMI tools remote
method invocation
·
Security tools
·
Java development tools
·
Java Web service tools
·
Java scripting
tools
·
Java
troubleshooting tools
1. Basic tools
In basic tool
contain tool used to create build application like Java, Javajdb, appletviewer,
JAR etc.
2. RMI tools
IMEI tools
help to create application that interacts over the web or the network which
consist rmi and rmi registry.
3.
Security tools
Security tools help you to set security
policy on your system and create application that can work within the scope of
the security policy which consists of the CI tools Jaya signature policy tools
extra
4.
Java development tools
Development tools used for development
of the JAVA application and web application it provide a complete UI for
development environment which consists NetBeans eclipse etc
5. Java Web service tools
Web service tools provide Java
architecture for building web application and parsing XML data from one site to
another site
6. Java scripting
tools
Java scripting
tools enable user to run external programming on the Java Platform it might not
be available in the JDK version means it install separately
7. Java
troubleshooting tools
Troubleshooting can be used for
understand a task that may generate error at runtime as well as in a future
Question 6: Compiling and Executing Basic Java Program
· Java is a platform
independent language which allows user to build Complex dynamic programming.
·
Java is also known
as object oriented and it follow the rules of object oriented programming all
the Java programs are written in a default text editor and Windows provide a
Notepad as a text editor.
·
Following is a
simple basic Java programming to display hello message on the screen.
class Abc
{
public
static void main(String args[])
{
System.out.println
(“Welcome To Java”);
}
}
}
·
According to Above
example ABC is the name of the class and the program should be saved with the
same name as the class name.
·
The public keyword
is an access specifier which means that the content of the following block
accessible from all other classes.
·
Static keyword allow the main functions to be
call without having two instance of a particular class.
·
The keyboard voice
tell the compiler that main function does not return any value and main is
method called when the Java program begin.
·
Java is a case
sensitive first of all the Java program is compiled by the javac command and
create a byte code is a class file.
·
And using a Java
interpreter Java Virtual Machine allow to run program on a device.
·
System is a
predefined class that provide access to the system.
·
That is a connected
to the console device how does output stream that is connected to the control
device.
· Print a line is a method
to display the stream which is passed to it.
Question 7:
Java IDE
Java IDE is a
software application which enable user to more easily write and debug Java
program
Many ID provide
feature like Syntax highlighting code compilation output window etc
The user to God more
easily following is some list of the Java ID
1.
NetBeans
2. Eclipse
3.
JC creator
4. Processing
5.
J builder
6.
Kawa
7. Dr.java
1.
NetBeans
·
The NetBeans ID is
a free and open source ID for software developers the ID is run on many
platform including Windows Linux Mac OS
·
It is easy to
install and also easy to create Java application
2.
Eclipse
·
Eclipse is free and
open source ID and also provide a developer tools Framework that can be
extended for a particular development need eclipse was also made to complete
with Microsoft Visual Studio eclipse give a similar standard way of developing
code in a Java language
Question 8: Data types
·
Every variable has
data type.
· Data type define
that which type of value are stored in variable and it also define the size of
a different data type.
· Allow the
programmer to use suitable type for the application Java define range of data
and behavior of primitive data type following is list of primitive data type
by the Java language
·
Integer
·
Float
·
Character
·
Bullion
· All about define
data types variables are the name of the memory location that can hold the data
value of the type variable can take different values during execution of the
program.
· When the variable
are declared in a Java Program there need to be a sign some value before use it
Question 9 : Java tokens
- Token is smallest element of a program
- That is a meaningful for the compiler.
- This token define the structure of Java language when you submit the Java program to Java compiler
- The Java compiler pass the text and act as a individual talk on following different categories
·
Keyboard
·
Literal
·
Identifier
·
White space
·
Separators
·
Comments
·
Operators
1.
Keyboard
It is a special type of reserved word
for specific purpose which cannot be used as identifier means cannot be used as
a name for a variable class method etc
There are Number of keywords are
currently defined in a Java language
2.
Literal
Constant in Java
are call literal entity they do not change their value in a program during its
execution are call literal integer
Literal in a java
roll number there are three types of integer literal that is a decimal octal
and hexadecimal
A number with
decimal point and fractional value are call floating point literal floating
point literal are represented in one of the two forms that are standard and
scientific
Character literal
in Java are single character literal Java support a set of characters literal
are also known as escape sequence which cannot be printed like \n \t etc...
Price send a
sequence of character in a paragraph or double Kota is a continue as string
literal
In Java Boolean
literal take value true or false the Boolean value true is related to number 1 and false to number 0 as
in the case of the language C and C++.
3.
Identifiers
Identifiers are used
for class name method name and variable name an identifier may be any
descriptive sequence of uppercase lowercase letter number and underscore and
Dollar sign character
They must not begin
with a number Java is case sensitive so value is different identifier than the
actual value
4.
White space
Java is a free from
language this means that you do not need to follow any specially rules for
example if you return a Java Program in a single line not in a structure there
after you tell how to execute and run as a console application in a java
whitespaces space tab and newline
5.
Separators
Separator are used
to indicate where group of Quad divided into more than one part and orange it
they are basically define the shape and functions of our code following is the
list of separators available in Java
Parenthesis: Parenthesis are used to contain a list
of parameter in a method definition
Curly Brackets: Curly Brackets used to contain the
value of automatically initialise and used to define
block of code for classes method and local scope.
Brackets: This
are used to declare array types value.
Semicolon: Semicolon is used for terminate the
statements.
Coma: It
is used to change statement together inside another statement.
Comments: Comment is used for program definition
which is refer in future developer can give comment in program with multiple
ways compiler ignore the statements which are under the comment block to define
comment in java use /* …………. */
and // double slash
Question
10: OOP Concept
Class:
·
Class is a collection of
data member and data function
·
Class is a template that
define the form of an object
·
Class is an
implementation of conceptualization concept of OOP
·
Class is nothing but one
kind of structure of data binding
· Class is user defined data
type we can use class in a main function or in any event using an object
·
Object is a variable or
instance of the class
·
We can create as many
instance of class as we want
·
Usually with the help of
class we define a big project in a small part class make modification and
improvements of large and complex program
· Usually we create data
member as a private and member functions are public but it is not compulsory
·
Class contains
constructor destructor nested class methods etc.…
Object
·
Object key to understand
object oriented Technology
·
An object is an entity
that has state and behaviour
·
It can be physical or
logical tangible or intangible
·
Following is some
characteristics of an object
State:
State
the present data value of an object
Behaviour:
Present behaviour or a functionality of
an object such as amount deposit in a bank and withdraw from the bank
Identity:
Object identity is typically implemented using a unique ID the value of the ID
is not visible to the external user heat is used internally by the system to identify each object
uniquely
· For example
Pen is an object its name is Semisoft and its colour is a blue it is known as a
state
· and it is used to write
something so writing is its behaviour
· Object is an instance of
a class. Class is a blueprint or template from which object are created
· so, the object is an
instance of a class
Encapsulation
·
Encapsulation
is an object oriented programming based concept.
·
Encapsulation protect
important data inside the class
·
Which we do not want to
be exposed outside the class and
·
Encapsulation process
means binding the data member and Member function in single unit
·
Data member means
variable property etc... while the Member function means method and the class
is one of the best example of an encapsulation
·
Encapsulation
hide private or unwanted data from outside the class
·
With the Encapsulation we can make variable
property and method to private
Inheritance
·
Inheritance is a
mechanism in which one class acquire all the properties and behaviour of
another parent class
·
The idea behind Inheritance
is just you create a new class that are built upon an existing class
·
When you inherit from an
existing class you can reuse method and field of parent class you can add new
method and field also
·
Inheritance represent “is
a” relationship. It is also known as parent child relationship
·
Inheritance also known as
generalisation
·
Java use extend keyword
to create inheritance
·
The main advantages of
inheritance
1. Reusability
2. Save
time
3. Help
in modularization of code
Polymorphism
·
Polymorphism is a concept
by which we can perform a single action by different ways
·
Polymorphism is derived
from Greek word where poly means many and morphism means forms,
·
So polymorphism means
many forms there are two types of polymorphism in Java
1. Compile
time polymorphism
2. Runtime
polymorphism
· We can perform
polymorphism in Java by method overloading and overriding
·
If overload static method
in java it is the example of compile time polymorphism
· While the runtime
polymorphism are the dynamic method dispatch is a process in which a call to an
overloading is resolved at runtime rather than Compile time.
· In this process
overriding method is call to the reference variable of a superclass
· The determination of the
method to be call is based on object being referred by the reference variable
· Polymorphism can be
static or dynamic
· In a static polymorphism
response to a function is determined at the compile time and the dynamic
polymorphism is decided at runtime
· The static polymorphism
linking function with an object during compile time is called early binding it
is call Static Binding
· In a dynamic polymorphism
you have to create abstract class that used to provide partial class
implementation of an interface.
· Implementation is a
completed when derived class inherit from it.
· Abstract
class contain abstract method which are implemented by derived class
Question 11: Constructor
·
Constructor are special
Member function whose task is to initialise the object of its class
·
It is treated as a
special Member function because its name is same as the class name
·
Java constructor are invoked
when the object is created
·
It is a name such because
it construct the value it means provide the data from the object
·
It means there are used
to initialise the object
·
Every class has
constructor when we don’t explicit declare constructor from any Java class
·
The compiler create a
default constructor for the class which does not have any return type
·
Following is some
characteristics of constructor
1. Interface
cannot have constructor
2. Constructor
cannot be private
3. Constructor
can be overloaded
4. Constructor
cannot return a value
5. Constructor
do not have any return type not even void
6. Abstract
class can have constructor
7. Constructor
name must be similar to the class name inside which is created
8. Constructor
are automatically call when an object is created
9. Instance
variable and method of a class are known as member of a class
10. Constructor
are not a member for this reason constructor cannot be inherited but can
be
accessed by subclass
Constructor do not get inherited only
their member like variable and the method get inherited so declared a class as
a final is useless and has no meaning as a constructor cannot be overriding
There are two types of the
constructor
1. Default
constructor
2. Parameterized
constructor
Constructor having a no any parameter is
known as default constructor or non-parameterized constructor
A
constructor having an argument is known as parameterized constructorQuestion 12: Finalize () method
·
Sometime an object may
fall under automatic deallocation by Java but it is need to perform some action
·
Then the object is to be
save from automatic instructions to handle such a situation
·
Java provide a mechanism
call finalize with the use of method finalize
·
This finalize Method can
be put inside the class before the object is destroyed
·
Java run finalize method
before it goes for the object destroy
·
User can define whatever
action is to be taken inside the finalize()
·
By using finalize we can
define a special action that will occur when an object is just about to
reclaimed
by the garbage collection
·
Following is a Syntax to
define a finalize() method
public
void finalize()
{
Finalize code
}
}
According to above syntax the finalize ()
method will specify the action that must be perform before an abject is
destroy.
class FinalizeExample
{
public void finalize()
{
System.out.println(“Finalize Method Call”);
}
public static void main(String []args)
{
FinalizeExample f1 = new FinalizeExample();
FinalizeExample f1 = new FinalizeExample();
f1 = null;
f2 = null;
System.gc();
}
}
}
According to above
example finalize method call automatic. If the object is no longer require
using System.gc() method.
Question 13 : Static and
nonstatic member
·
A
class member must be access the use of an object of it’s
class
· But sometime we want to
define a class member that will be used independently without creating any
object of that class
·
It is possible in Java to
create a member that can be used itself without reference to specific and instance.
·
To create such a member prefix
declaration with static keyword
· When a member is declared
static it can be accessed before an object of a class are created and without
reference to any object
· One can declare both
method and variable to be static the most common example of static member is
main function main function
·
Main() function is
declared as static because it must be called before any object
·
Instance variable
declared as a static actually global variable when objects of its class
declared no copy of static variable is made
·
When we declare method as
static there are several restrictions that is...
·
1. one call only another static method
·
2. only access static
data
·
3. cannot refer to this
or super in any way
· Following is an example
of static variable and static method
· Example...
· According to above
example class student continent instance variable as well as static variable
·
it means in string variable call separately
when an object is created by the static member variable assign its value for
all the objects
· It means it not allow to access separately by
the object
Question 14 : overloading
constructor
·
Constructor is special
Member function of a class and it’s not return a value even void whenever object create
constructor call automatically because it used to initialize the value of the object field
·
Java support the concept
of constructor overloading it means constructor is
called based upon the parameters specified that the time of object creation
· Sometimes there is need
to initialize an object in different
ways and this can be done using constructor overloading
· In a constructor
regarding the name of the constructor you must be same while the number of
argument or type of argument must be differ from each other
·
Syntax...
·
Example...
·
According to above example
class Abc have to constructor first is non-parameterize constructor and second
is parameterize constructor.
Method overloading ::
·
If class have multiple method
having same name but different in
parameters it is known as Method overloading
·
If we have to perform
only one operation having same name of the method it increase readability of
the program
·
We can define method loading
and different two ways
1. By changing my number
of argument
2. By changing the data
type
·
It allows users to define
same name method with different signature due to this reason we do not need to create a
different method for same purpose with different name
Syntax...
·
According to above syntax
class is a keyword to create class and class name is name of the class which contain two separate method which is either different from there datatype
or may be number of argument
Example...
Please Share and Comment it... Thank You
:: Best Of Luck ::
https://myshopprime.com/uday.shah3/shop