Академический Документы
Профессиональный Документы
Культура Документы
&
JSE [CORE JAVA]
by:-MOHIT SINGH
by:-MOHIT SINGH
by:-MOHIT SINGH
Procedural programming:-
by:-MOHIT SINGH
>>
When you need to reuse the procedural
program in another application, a change in
the application results in rewriting a large
portion of the code.
This results in decreased productivity and
increased maintenance cost of the
application. This was one of the reasons that
led to the evolution of the object-oriented
approach.
by:-MOHIT SINGH
>>
by:-MOHIT SINGH
Advantages of OOPS:-
Real-world programming
Reusability of code
Modularity of code
Resilience to change
Information hiding
by:-MOHIT SINGH
>>
Real-world programming
The object-oriented approach models the real world
more accurately than the conventional, procedural
approach.
Reusability of code
In the object-oriented approach, you build classes,
which can be used by several applications.
Modularity of code
An object can be maintained independently of other
objects.
Resilience to change
Object-oriented programming also enables you to
evolve various versions of software.
When a change is suggested, the old system need not
be completely abandoned and re-built from scratch.
Information hiding
Information hiding ensures data security in a program.
by:-MOHIT SINGH
Encapsulation
Abstraction
Inheritance
Polymorphism
by:-MOHIT SINGH
Need of Java:-
>>
Servlets: Servlets are the programs that
by:-MOHIT SINGH
Characteristics of Java:-
Simple
Object-oriented
Compiled and interpreted
Portable
Distributed
Secure
Robust
by:-MOHIT SINGH
How the Java Byte code and the JVM together make Java programs portable on
different platforms :-
by:-MOHIT SINGH
Objects:-
>>
An object means a material thing that is
by:-MOHIT SINGH
Class:-
similar type.
A class captures the common
properties of the objects instantiated
from it.
Class is just a Blueprint. It means it is
not having any physical appearance.
by:-MOHIT SINGH
by:-MOHIT SINGH
>>
by:-MOHIT SINGH
>>
Girls have state , such as name, color, age,
and height
and
behavior such as walking, dancing, and
sleeping.
by:-MOHIT SINGH
An ATM user:-
by:-MOHIT SINGH
Abstraction:-
existing class.
Enables you to add new features and
functionality to an existing class without
modifying the existing class.
Enables you to share data and methods among
multiple classes.
You create a class that inherits the attributes
and behavior of another class. Attributes refer
to the data and behavior refers to the methods.
by:-MOHIT SINGH
For ex:-
by:-MOHIT SINGH
Kind-of
Is-a
Part-of
Has-a
by:-MOHIT SINGH
For example:-
by:-MOHIT SINGH
by:-MOHIT SINGH
loader
Execution engine
Just In Time (JIT) compiler
by:-MOHIT SINGH
by:-MOHIT SINGH
Defining Variables:-
Class variables
Instance variables
Local variables
Static variables
Automatic variables
by:-MOHIT SINGH
Integer literals
Floating point literals
Character literals
String literals
Boolean literals
by:-MOHIT SINGH
by:-MOHIT SINGH
Creating Classes in Java:Various data members and methods of a class are defined
inside a class. The statements written in a Java class must end
with a semicolon, ;. The following syntax shows how to declare
a class:
class ClassName
{
//Declaration of data members
//Declaration of methods
}
by:-MOHIT SINGH
unique identity.
Creating
Classes:TheObjects
identity of anof
object
distinguishes it from
other objects.
Classes and objects are closely linked to each
other. While an object has a unique identity, a
class is an abstraction of the common properties
of various objects.
by:-MOHIT SINGH
by:-MOHIT SINGH
by:-MOHIT SINGH
constructor.
A constructor returns the instance of
the class instead of a value.
A constructor is used to assign values
to the data members of each object
created from a class.
by:-MOHIT SINGH
>>
Interfaces also enable you to declare
>>
It is 100% abstract class. It contains two
>>
We cannot use the private and protected
by:-MOHIT SINGH
by:-MOHIT SINGH
Packages:-
by:-MOHIT SINGH
interfaces.
This is basically used to do graphical programing.
The AWT defines windows according to a class
hierarchy that adds functionality and specificity
with each level.
The main purpose of the AWT is to support
applet windows, it can also be used to create
stand-alone windows that run in a GUI
environment, such as Windows
by:-MOHIT SINGH
>>
The API of the AWT package consists of a
by:-MOHIT SINGH
It is an extension of AWT.
Swings Components offer Cross Platform
by:-MOHIT SINGH
>>
Swing components also provide GUI
by:-MOHIT SINGH
>>
Applets are basically web programming.
by:-MOHIT SINGH
Applet class:-
by:-MOHIT SINGH
by:-MOHIT SINGH
>>
by:-MOHIT SINGH
>>
by:-MOHIT SINGH
>>
by:-MOHIT SINGH
Or:-
by:-MOHIT SINGH
Applet States:-
by:-MOHIT SINGH
first loaded.
Running(start):-for the first time, It is
automatically called by the system after
init() method execution. It also invoked
when applet moves from idle/stop() state to
active state.
Display(paint):- it happens immediately
after the applet enters into the running
state. It is responsible for displaying output.
by:-MOHIT SINGH
>>
Idle(stop):- it is invoked when the applet
by:-MOHIT SINGH
In HTML , elements are of two types:1. Container:- are those which having the
start tab and end tab.for ex:<html>..</html>
2. Empty:- are those which are having only
start tab. For ex:-<br/> , <body
bgcolor=value>
by:-MOHIT SINGH
>>
Java has various predefined classes of
layout managers.
All layout managers make use of the
setLayout() method to set the layout of
a container.
If the setLayout() method is not used,
then the default layout of the
container is set.
FlowLayout Manager:The
GridLayout Manager:The grid layout is the layout that divides the container
>>
You need to specify the constraints for
by:-MOHIT SINGH
>>
All the registered listeners are notified about the
Sources:-
Checkbox
Button
List
Text components
Scrollbar
Window
by:-MOHIT SINGH
by:-MOHIT SINGH
by:-MOHIT SINGH
Event Classes:-
by:-MOHIT SINGH
>>
The main methods included in the
by:-MOHIT SINGH
java.awt.event.InputEvent class.
The mouse event indicates that a mouse
action has occurred on a component.
The MouseEvent class is used for both,
mouse events and mouse motion events.
The mouse event class defines some
integer constants that can be used to
identify several types of mouse events.
by:-MOHIT SINGH
>>
The mouse events include:
Pressing a mouse button
Releasing a mouse button
Clicking a mouse button
Entering of mouse in a component area
Exiting of mouse from a component area
by:-MOHIT SINGH
>>
The syntax of one of the constructors of the
by:-MOHIT SINGH
>>
by:-MOHIT SINGH
>>
AdjustmentListner:- Defines the
>>
You can define a class that acts as an
by:-MOHIT SINGH
exceptional event.
An exception can be defined as an abnormal
event that occurs during program execution
and disrupts the normal flow of instructions.
Errors in a Java program are categorized into
two groups:
Compile-time errors
Run Time errors
by:-MOHIT SINGH
>>
Concept of Exceptions:The unexpected situations that occur during
by:-MOHIT SINGH
Exception hierarchy:-
by:-MOHIT SINGH
>>
Throwable Class:- The Throwable class is a
>>
The built-in exceptions in Java are
by:-MOHIT SINGH
by:-MOHIT SINGH
>>
You can implement exception-handling
by:-MOHIT SINGH
by:-MOHIT SINGH
Multiple catch statements:A single try block can have many catch
Finally:-
by:-MOHIT SINGH
throw ThrowableObj
by:-MOHIT SINGH
>>
If no parameters are passed to the super()
>>
The syntax to access the member
by:-MOHIT SINGH
current object.
You can use the this keyword when a
method defined in a Java class needs to refer
to the object used to invoke that method.
Another situation where you can use the this
keyword is when the local and instance
variables have the same name.
In addition, you can use the this keyword in
a constructor of a class to invoke another
constructor of the class.
by:-MOHIT SINGH
>>
Unlike the super keyword, the this keyword
>>
The syntax to declare the final variable is:
final int MY_VAR=10;
>>
Program.
by:-MOHIT SINGH
>>
If a process is made of one thread is
>>
Runnable is the predefined interface it
by:-MOHIT SINGH
File Handling:-
by:-MOHIT SINGH
>>
File class does two operations:If file is not there it just create the logical file.
If file is already there it just open that file in the
memory.
>>
read is the predefined function , it accept a
by:-MOHIT SINGH
>>
We can read & write the data in a file in
two format:Binary
Character
>>
For writing and reading in the binary
by:-MOHIT SINGH
>>
File Input Stream is the predefined class it
by:-MOHIT SINGH
>>
When we want to read and write the data in the
character format that time we use two classes:Reader class
Write class
>>
Syntax of writer class:String str=character stream classes in java;
File Writer fout= new File Writer(evening.txt);
Fout.write(str,0,str.length());
Fout.close();
by:-MOHIT SINGH
>>
File Reader and File Writer are the low
level classes but Buffered Reader and
Buffered Writer are the high level
classes.
by:-MOHIT SINGH