Académique Documents
Professionnel Documents
Culture Documents
com
Java in Hindi
Third Edition
By Prof. V.K. Sharma
2015
www.besthinditutorials.com
Java in Hindi
Third Edition
V.K. SHARMA
www.besthinditutorials.com
Limits of Liability/disclaimer of Warranty: The author and publisher have used their best
efforts in preparing this EBook. www.besthinditutorials.com makes no representation or
warranties with respect to the accuracy or completeness of the contents of this book, and
specifically disclaims any implied warranties which extend beyond the descriptions contained
in this paragraph. No warranty may be created or extended by sales representatives or
written sales materials. The accuracy and completeness of the information provided herein
and the opinions stated herein are not guaranteed or warranted to produce any particular
results and the advice and strategies contained herein may not be suitable for every
individual. www.besthinditutorials.com shall not be liable for any loss of profit or any other
commercial damages, including but not limited to special, incidental, consequential, or other
damages.
Trademarks: All brand names and product names used in this EBook are trademarks,
registered trademarks, or trade names of their respective holders.
www.besthinditutorials.com is not associated with any product or vendor mentioned in this
EBook.
Contents
1.
2.
3.
4.
5.
6.
7.
8.
9.
INTRODUCTION TO JAVA
1.1. History of java
1.2. Features of java
1.3. OO principles of java
1.4. Java vs. c and c++
INSTALLING JAVA
2.1. Java development tools
2.2. Downloading java
2.3. Installing java and setting environment variables
2.4. Download eclipse
2.5. Installing eclipse
FIRST JAVA PROGRAM
3.1. Running a java program
3.2. Hello world program
DATA TYPES
4.1. What are data types?
4.2. Integer
4.3. Float
4.4. Character
4.5. Boolean
VARIABLES
5.1. What are variables?
5.2. Types of variables
5.3. Creating variables
STRINGS
6.1. What are strings?
6.2. Operations on strings
ARRAYS
7.1. What are arrays?
7.2. Creating an array
7.3. Initializing an array
7.4. Displaying an array
OPERATORS
8.1. What are operators?
8.2. Types of operators
Control Statements
9.1. What are control statements?
9.2. Types of control statements
10. CLASSES
10.1. What are classes?
10.2. Advantages of classes
10.3. Creating a class
11. OBJECTS
11.1. What are Objects
11.2. Steps to create an object
12. CONSTRUCTORS
12.1. What are constructors?
12.2. Rules for creating constructors
12.3. Types of constructors
13. METHODS
13.1. What are methods?
13.2. Structure of method definition and method call
14. INHERITANCE
14.1. What is inheritance?
14.2. Types of inheritance
14.3. Inheriting a class
14.4. Example
15. Exception Handling
15.1. What are exceptions?
15.2. Keywords(try, throw, catch)
15.3. Example
16. Interfaces and packages
16.1. What are interfaces?
16.2. Example
16.3. What are packages?
16.4. Creating a package
16.5. Using a package
16.6. Some common java packages
17. Multithreading
17.1. What is multithreading?
17.2. Thread class
17.3. Runnable interface
17.4. Synchronization
18. File I/O
18.1. What are streams?
18.2. Byte streams
18.3. Character streams
19. Serialization
19.1. What is serialization?
20.
21.
22.
23.
24.
25.
26.
27.
Preface
The idea of writing a book about Java Development in Hindi can be somewhat futile at times,
considering the pace at which Java continues to expand, morph and change. What started
out as a book project two years ago has now become a series of updates to the original work
with the page count nearly double the original project and that after making hard decisions
about what to leave out of the book to make sure it gets liked.
This update to Java in Hindi represents our latest effort to provide coverage on important
Java Development topics, namely the expansion into the Swing.
Like many things in life, the only constant is change, but by now we are somewhat
accustomed to the rapid-fire environment of Java Development. To the end, we have
ensured that all the programs work with eclipse as well as without eclipse.
The third edition is written by Vipin Kumar Sharma. Thank you for learning and collaborating
with us.
Acknowledgement
Writing a third edition of Java in Hindi feels somewhat like the old saying about weddings:
Something old, something new The deadline for the third edition did not become any
easier as at last count there are still only 24 hours in the day. And as for something new it
seems as though Javas pace of innovation is continuing to match its adoption rate by users
around the globe.
Road map
1. Basic first 10 chapters contain basic information regarding java programming.
2. Intermediate next 10 chapters are somewhat of intermediate level and necessary
java topics.
3. Advanced remaining chapters covers some advanced topics of java language.
Chapter 1
Introduction
This chapter covers
History of Java
Features of Java
OO Principles
Java vs. c and c++
History of Java
Java general purpose object oriented
. Sun Microsystems
. Java
U.S
develop
. Java
oak
java
develop
execute
java 1991
. Java
. Java
java
java
Features of Java
java
java
java
interpreted
two
generate
instructions
generate
java
.
java
directly execute
JVM
generate
generate
execute
JVM
machines
JVM
. Java
compile
java
JVM
generate
generate
.
.
3. Object Oriented
Java true
. Java
. Java
java
technologies
crash
reliable
. Java
JVM
Java
environments
invalid combinations
generate
JVM
5. Distributed
Java
distributed applications
networks
. Distributed applications
task
applications
RMI
. Java
. Java
c c++
java easy to
variables
java c c++
c c++
java
familiar
java
8. High Performance
java
.
impressive . Java
reason
java architecture
. Java
java
. Java
dynamic
Java
java extensible
Java
. Java
.
.
java
. Java
principles
1. Encapsulation
Encapsulation data hiding
(variables)
. Encapsulation
.
bind
(Methods)
. Encapsulation
. Java 3
hiding
Public -
Private -
Protected -
2. Inheritance
. Java
allow
java
3. Polymorphism
Polymorphism
"
according
". Polymorphism
actions
4. Abstraction
Abstraction java
concept .
same
1.
program objects
C procedural language .
C
functions
.
interpreted compiled language
2.
language
directly
JVM
convert
4.
convert
convert
3.
C compiled language . C
C low
.
language . C language machine
.
bottom up approach
.
pointers
5.
pointers handle
.
memory automatically
6.
8.
error
. C overloading
error
overloading support
7.
exception handling
.
C
Java Vs C++
1. C++ structures, unions, templates, operator overloading pointers support
2. C++
collection
3.
threads
destructors
built in support
. C++
C++
automatic garbage
resolution operators
5. C++
goto statement
6. C++
method overloading
method overloading
default arguments
arguments
support
libraries
4. C++
goto statement
compiled
default
.
.
operator overloading
7. C++
platform independent
interpreted
Chapter 2
Installing Java
This chapter covers
. JDK
JRE
execution
execute
. JRE
execute
JRE 2
1.
2.
execution
Machine ) environment
JRE
compile
convert
convert
command prompt
java
official
editor
IDE
environment
NetBeans IDE milega
Eclipse
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Eclipse IDE
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/marsr
Chapter 3
First Java Program
This chapter covers
notepad
console
console
IDE use
java
IDE
IDE
Eclipse, NetBeans
IDE Java Compiler execute
.
Through Console
Console
1. Run
program
cmd
2. Command prompt
steps
command prompt
drive
install
3.
enter
image
javac
4.
MyProgram.java.
prompt
.java extension
javac MyProgram.java
errors
executable file
javac command
enter
5.
java MyProgram.
copy
lecturer
board
simple
notepad
java program
chapter 2
message
main
HelloJava
println
description
members
(public, private,
tutorials
class -
important concept
static
HelloJava keyword
method
main
program execute
access
main -
main
execution
execute
. Class
String args [] -
argument
, println
.
Chapter 4
Data Types
This chapter covers
available
according
???
.
operations
operations
perform
operations
and Division)
perform
categories
Integer
Integers
(
4
) include
.
Byte
. -127
128
.
.
Short
16
32,767
-32,768
.
Example - short sal = 25,000
Int
Int
32
commonly
2,147,483,747
. Int
-2,147,483,648
64
Floating-Point Numbers
numbers
)
.
Float
3.4e+038
32
1.4e-045
.
Example - float temp=34.4;
Double
1.8e+308
64
4.9e-324
Character
char
16
Boolean
decision
true
false.
Chapter 5
Variables
This chapter covers
information
changeable
. Variable
constant
create
. information
error generate
information
change
Information
data type
Java
scope
Local Variables
.
.
Global Variables
variable
variable
global variables
scope
Creating Variables
Java
create
stages
Variable Declaration
initialize
declare
argument
(System.in)
nextInt(), nextLine(),nextFloat
Scanner
Example -
Chapter 6
Strings
This chapter covers
compare
. String
strings objects
operations
.
normal variables
object
string
Example
String variable
MyString
object
string variable
methods
provide
modification
string object
generate
string object
Operations on Strings
String Length
string
length( )
string length
characters
Example
String Concatenation
Example
strings
string concatenation
Example
charAt( ) method
method
array
Example
indexing
character extract
character extract
string
Equals( ) method
compare
false
equal
compare
argument
true
Example
indexOf( ) method
string
index
sub-string extract
sub-string
Example
substring( ) method
.
start index
start
end index
Example
Chapter 7
Arrays
This chapter covers
Array
syllabus
array
. Arrays programming
Array similar
need
variables
array
. Array
.
topic
word
programming
similar
employees
variables
size
index
BCA
access
array
array index
Arrays index
. Array
classmate
array
arrays
element
first
lecturer
array
.
.
zero
array
array
element (n -1)
array size 5
array
array index
element 22 4th
Creating an array
Java
array
array
keyword
size of array -
Example
array
Initializing an array
Arrays
initialize
array
particular index
Example
salary [4 ] = 10000;
array
array
Example
Displaying an array
array values
Example
System.out.println(salary[4]);
Example
Multidimensional arrays
dimensions
array example
row column
array
. two dimensional
Chapter 8
Operators
This chapter covers
operators
operations perform
operations
.
2
operands
unary binary .
operand
. Unary
apply
2 operands
6
1.
2.
3.
4.
5.
6.
Arithmetic Operators
Logical Operators
Bitwise Operators
Relational Operators
Assignment Operators
Conditional Operator
Types of Operators
Arithmetic Operators
Arithmetic
5
a=5, b=3;
Example
c = a+b;
Subtraction
Subtraction
subtract
a =10, b=9;
Example
c = a-b;
Multiplication
multiply
a =3, b=3;
Example
c = a*b;
Division
a=10, b =2;
Example
c = a/b;
Modulus
a= 10, b=3;
Example
c = a%b;
Logical Operators
operators
operations
true
true
false
true
.
true
3
false.
Example
c = a&&b ; // c
false
Logical OR (||)
true
true
a= true, b = false;
Example
c = a&&b; // c
true
Bitwise Operators
by
.
Bitwise OR (|)
right
. Right
compute
IF
Equal to (==)
true return
equal
equal
true return
true return
true return
Assignment Operators
left
subtract
multiply
according
Example
a = 5, b = 3;
a
c = a>b ? a : b //
Chapter 9
Control Statements
This chapter covers
even
execution
execute
. Iteration statements
statements
. Jump
.
execution (
according
odd.
even
email id
according
. Java
execute
execute
execute
execute
false
3
IF Statement
if ( condition )
{
//
execute
execute
condition
condition
execute
Example
int a = 5, b = 3;
if ( a > b)
{
System.out.println("A is bigger than B");
}
IF Else Statement
execute
if ( condition )
{
// when condition true
}
else
false
-
false
else
. If
execute
execute
condition
Example
int a = 5, b = 3;
if (a > b)
{
System.out.println("A is bigger than B");
}
else
{
System.out.println("B is bigger than A");
}
Nested IF Statements
if
condition
Example
int a = 4;
if (a > 0)
{
if( a /2 == 0)
{
System.out.prinln("A is Even" );
}
}
execute
execute
Switch Statements
according execute
according
.
Example
int num = 3;
switch (num)
{
case 1 :
System.out.println("f number is 1");
break;
case 2 :
System.out.println("if number is 2");
break;
case 3 :
System.out.println("if number is 3");
break;
defalut:
System.out.println("if number does not match any
condition");
break;
}
case
example
execute
variable
execute
execute
execute
Iteration Statements
execute
iteration
execute
statement
execute
.
false
execution
execute
. Iteration
looping
For Loop
Example
Initialization
initialization
Condition
execution
execute
?.
execute
initialized
Increment
initialized
execute
?
Example
class IterSta
{
public static void main(String args[])
{
for(int i =1; i<=10; i++)
{
System.out.println("Numbers from 1 to 10");
System.out.println(i);
}
}
}
. While
initialization
initialization;
while (condition)
{
// statements
increment;
}
Example
class WhileStat
{
public static void main(String args[])
{
int i =1; // initialization not compulsory
while( i<=10) // condition
{
System.out.println(i);
i++; // increment
}
While
. While
execute
execute
execute
do-while
execute
execute
execution
.
Example
class DoWhileStat
{
public static void main(String args[])
{
int i=0; //initialization
do
{
System.out.println(i);
i++; // increment
}while(i<=10) // condition
}
}
Jump Statements
Break statement
cases
execution
execute
break;
Continue statement
divide
100
iteration
iteration
iteration execute
100
Example
continue;
Return statement
Return
return
.
.
Example
return;
return
Chapter 10
Classes
This chapter covers
??
???
.
entity
attributes
entity
, ,
java
execution
Advantages of Classes
advantages
Security
.
Reduce Complexity
complexity
Separation
(methods)
(methods)
Purchases
Sales
Focus on Data
Creating a Class
Example
class Person
{
String Name="Vipin";
int age=24;
age .
name
execution main
Main Method
execution
static
environment
execute
static
. Static
environment
.
Static Variables and Methods
array
according
Chapter 11
Objects
This chapter covers
new
.
5
1.
2.
.
3.
equals (=)
4.
new
5. New
.
Example
class Person
{
class PersonObj
{
public static void main(String args[])
{
Person p1 = new Person();
p1.display();
}
}
example
execution
PersonObj
()
class
constructor
create
initialize
constructor
? Constructor
(.)
constructor
Person p1;
p1 = new Person();
objects
.
create
Example
Person p1:
initialize
reference variables
Chapter 12
Constructors
This chapter covers
initialize
memory
constructor
initialize
. Constructor
Constructor
return
,
.
1. Constructor
2. Constructor
return
same
problem
allocate
automatically
default constructor
allocate
alloacate
according
initialize
initialize
Types of Constructors
4
constructors
explain
Default Constructor
constructor
Constructor
constructor
Normal Constructor
constructor
Example
class Person
{
String Name;
int age;
Person() //Constructor
{
Name = "Vipin"
age = 24;
}
class NorCon
{
public static void main (String args[])
example
automatically
constructor
Parameterized Constructor
constructors
parameters
variables
assign
Example
class Person
{
String Name;
int age;
class NorCon
{
public static void main (String args[])
{
Person p1 = new Person("Vipin",24 ); // calling constructor and
initializing object
p1.display();
}
}
example
initialize
create
Copy Constructor
constructor
same
constructor
argument
Example
class Person
{
String Name;
int age;
class CopyCon
{
public static void main (String args[])
{
Person p1 = new Person("Vipin",age);
Person p2 = new Person(p1); // calling constructor copying object
p1.display();
p2.display();
}
}
same
example
.
Chapter 13
Methods
This chapter covers
perform
??.
text
println() method.
separate
-
Access specifier
public
private
static.
Return type
execution
int
return
string.
Method name
method
Argument list
variables
return
If in another class
object_Name.method_Name();
Example
class PersonsInfo
{
addition
return
Age:24");
Separator();
System.out.println("Name : Radha Age : 23");
Separator();
System.out.println("Name : Krishn
Age:24");
}
}
Output
method
persons
return type
void
Chapter 14
Inheritance
This chapter covers
What is inheritance
Types of inheritance
Inheriting a class
Example
What is inheritance?
class
class
class
code
re-usability
class
class
extend
class
extends
extend
class
Final
.
.
class
implement
super
class extend
subclass
reuse
. Inheritance
multiple inheritance
allow
class
Final
inheritance
class
class extend
Inheritance
class features
class
subclass
Types of Inheritance
Single inheritance
extend
Class A
|
extends
|
Class B
Multilevel inheritance
extend
extend
Class A
|
extends
|
Class B
|
extends
|
Class C
Hierarchical inheritance
Class A
/
extends
/
Class B
\
extends
\
Class C
extend
Inheriting a class
inherit
extend
}
class yrclass extends otherclass
{
// now you can access other class public methods and variables
}
extends
}
public class MountainBike extends Bicycle
{
// the MountainBike subclass adds one field
public int seatHeight;
Chapter 15
Exception Handling
This chapter covers
. Exception
error
compile
out of memory
execute
exception
execute
memory
execution
situations
error
execute
Keywords
Java
structure
keywords
easy .
try
Catch
try
generate
catch
Throw
java
exceptions
exceptions
define
throw
java
Throws
method
throw
exceptions
generate
throws
exceptions
Finally
Exceptions
execute
execute
terminate
1.
2. Try
try
catch
exception generate
exception
generate
Example
catch(ArithmeticException e)
3. Catch
4. Exception
exception
situation
execute
exceptions
exceptions
message
. Exceptions
java
exceptions
skill improve
exceptions
java
Arithmetic Exception
arithmetic error
divide
ArithmeticException generate
.
Class Cast Exception
sub
ClassCastException generate
array
ArrayStoreException generate
string
Array-Index-Out-Of-Bounds-Exception
array
10
11th
11
ArrayIndexOutOfBoundsException generate
IllegalArgumentException generate
int
string
Java
reference null
assign
NullPointerException generate
string
number
NumberFormatException generate
null
.
Chapter 16
Interfaces & Packages
This chapter covers
. Interfaces
interfaces
Interfaces
object
create
. Method
extend
methods
interface
Interfaces
interfaces
Interfaces
fruit
Is-a relation
interfaces
establish
Is-a
mango
Is-a
mango
fruit
Mango is a fruit.
interfaces
public
public
interface keyword
public
Example
example
Fruit
Mango
example
Mango
???
problem
??.
error show
same
.
execute
possibility
.
problem
java
error generate
packages
same
. Packages
programmer productivity
category classes
Java packages
error
error
same
Package
package
maintain
packages
production
sales package
related classes
production package
Java packages
class
access modifier
same
classes
java packages
related classes
package
packages
java packages
amazing
Creating packages
Package
:
Example package newPackage;
Using packages
package
directly
access
import packageName.className;
Example import newPackage.myClass;
Java
package
packages
packages
java
tasks
common
packages
java.language
package
java
java.util
package
java.io
package
java.AWT
package
java.net
package
.
java.applet
package
Chapter 17
Multithreading
This chapter covers
What is multithreading?
Thread class
Runnable interface
Synchronization
What is multithreading?
JAVA
JAVA
Multitasking
Multi-threading
. multi-threading
Thread
run()
Runnable
thread
run()
Thread class
Thread
Thread
run()
Thread class
Runnable Interface
JAVA
thread
thread
start()
start()
t.start();
start()
1. getName
2. getPriority
3. isAlive
4. join
5. run
6. sleep
7. start
thread
. run()
execute
Thread
.
example
Thread
start() run()
Runnable interface
Runnable
Thread
start()
Runnable
argument
This
.
run()
This
start()
Synchronization
2
conflict
thread
resource
technique
.
.
technique
Synchronization concept
access
conflict
synchronization
thread
monitor
synchronized
lock
threads
waiting
suspend
Java
Synchronization 2
:-
1. Synchronized method
2. Synchronized statement
Synchronized method
synchronized
execute
Synchronized
Example:
class bank
{
synchronized void withdraw(int amount)
{
}
}
Synchronized statement
class
synchronized
synchronized
synchronized
Example:
Synchronized (s1)
{
//
}
synchronize
Chapter 18
File I/O
This chapter covers
input
console
.
enter
software
read
output
.
output
input
output
solution
file
??
read
input console
console
human
output
situation
provide
file
input
classes
output
text file
file
. Java
output
store
file
streams 2
Input Stream
Input stream
input
Output Stream
Output stream
output
Byte Streams
Byte stream
bytes
input output
2 classes
InputStream OutputStream.
InputStream class
abstract
class
FileInputstream class
extend
OutputStream Class
abstract
FileOutputStream
extend
FileInputStream Class
FileInputStream byte stream input
stream
object
call bytes
read( )
byte input
.
Example
FileOutputStream Class
FileOutputStream byte stream output
output stream
write
Example
.
write ( )
bytes
byte
example
byte stream
Character Stream
Character stream
bytes
input output
2 classes
character
. Character stream
Reader Writer .
Reader Class
Reader abstract
extend
. FileReader Class
Writer Class
abstract
FileWriter
FileWriter Class
extend
.
FileReader Class
FileReader character stream input classes .
character input stream
create
read ( )
data read
object
Example
FileWriter Class
FileWriter character stream output class .
output stream create
Example
object
write ( )
character
data write
Chapter 19
Serialization
This chapter covers
What is serialization?
Serializable interface
What is serialization?
process serialization
store
Object
object serialize
EmployeeName
process De-serialization
serialize
object restore
byte stream
state save
??.
.
save
stages
??.
store
employee
store
object De serialize
value memory
file
load
Serializable Interface
object serialize
interface implement
objects
serialize
Serializable
ObjectOutputStream Class
object file
store
FileOutputStream
ObjectOutputStream
serialize
Example
ObjectOutputStream
object
writeObject ( )
argument
object create
object
ObjectInputStream
Example
memory
.
ObjectInputStream
object
readObject ( )
Chapter 20
Collections Framework
This chapter covers
data structures
objects
. Java
objects
) perform
Collections framework
classes
collection
.
collection
interfaces implement
. Collections framework
data
objects organize
object
Collections Framework
normal
extend
classes provide
structure
organize
interfaces
data structure
interfaces classes
Collection Interface
collection define
Collection interface
methods .
interface methods
collections
interface implement
-
methods
Collection
List Interface
ArrayList LinkedList
objects
objects
store
. list collection
duplicate
ArrayList Class
LinkedList Class
Set Interface
HashSet TreeSet
. Set collection
. Set collection
duplicate
set collection
objects
collection objects
hash table
TreeSet Class
collection
Queue Interface
queue interface implement
PriorityQueue
First-In-First-Out form
queue collection
PriorityQueue Class
Map Interface
HashMap TreeMap class Map interface
value pair
store
. Map collection
elements unique
. Map collection
store access
.
data key
key
TreeMap Class
Iterator interface
interface iterator ( ) method provide
return
iterator interface
call
collection elements
create
through
Chapter 21
Lambda Expressions
This chapter covers
interface
interfaces
abstract
method
default abstract .
functional
. functional
Runnable
.
hello()
Welcome.
message
by
,Example:-
Example
interface Welcome
{
String hello(String name);
}
abstract
functional
. Lambda expression
conditions
execute
abstract
available
string
define
variable initialization,
lambda
available
expression
return type
body
lambda
(->)
(right)
available
(left)
conditions
body
lambda
class
lambda
Lambda expressions
conditions
lambda
Example
Welcome wel;
String name = "Vipin";
wel = (name)-> {
System.out.println("Hello"+name);
};
lambda expression
expression
lambda
string
functional
hello()
apply
lambda
Chapter 22
Generics
This chapter covers
addition method
data type
float
java
generics
execute
method
possible ???
data type
execute
readability
methods
Java
Generics
.
data type
integers
double
generic
. Java
class
class
declare
declare
generic
generic
variable declaration
constructor
object create
generic argument
convert
generic class
argument
different
object
Chapter 23
Applets
This chapter covers
save
HTML
visitor
load
Java.applet.Applet
important
HTML
load
.class extension
save
server
init ()
variables initialize
initialization
start()
init()
automatically
destroy()
paint()
start()
java.applet.Applet java.awt
Example
drawString()
coordinates
show
HTML page
argument
open
java
browser
setBackground()
example
browser
open
.
java
HTML
HTML
applet
.
html
java
param.
through
2 attribute
name value.
Example
<html>
<head>
<title>applet example</applet>
</head>
<applet code="picture.class" width="300" height="300">
<param name=userName value=Vipin Sharma>
</applet>
</html>
HTML
userName
. Java
Chapter 24
Abstract Windows Toolkit
This chapter covers
What is AWT?
Container classes
Component classes
Frame class
What is AWT?
Java
extended version
swing
create
calculator
. AWT
buttons , menus
notepad
AWT GUI
packages classes
java
applets
. AWT
java.awt.*
. AWT
.
AWT
AWT
Container - Frame,Window,Panel,Dialog
Component - Button,Label,TextFeild,RadioButton,ScrollBar,checkbox
Container classes
Container
components
base
. Container
main
components
available
Frame,
Frame
add(component obj)
add()
add()
Example add(b1);
setSize(height,width)
setSize()
width
height
Example setSize(100,100);
setLayout(layoutManager Obj)
setLayout()
LayoutManager
LayoutManagers
BorderLayout GridLayout.
Layout
null
Example setLayout(null);
setVisible(true or false)
setVisible()
true
visible
.
show
open
method
false
Example setVisible(true);
Component classes
Components
TextArea
interact
controls
.
standalone
components
container
.
components
methods
class represent
Example setBackground(red);
resize(height,width)
Example resize(30,30);
move(int,int)
Dimension
Example move(50,120);
setBounds(int,int,int,int)
starting
component position
Example setBounds(30,150,200,160);
Frame Class
Frame
AWT example
.
setSize(200,200);
Frame
add(lb);
. Frame
class guiButton
{
public static void main()
{
Frame f = new Frame();
Button b1 = new Button("Click it!!");
f.add(b1);
f.setTitle("Button Example");
f.setSize(200,200);
f.setVisible(true);
}
Chapter 25
Servlets
This chapter covers
java
generate
submit
input
dynamically
advantages
. Servlet
java servlets
advantages
Servlets execute
Servlets
Servlets secure
independent
.
better .
java
2 packages import
javax.servlet
interfaces
java
servlets
GenericServlet
javax.servlet.http
http
Architecture of Servlets
servlets
development support
servlet
HttpServlet
Tasks of servlets
servlets request
processing
requested
(browser)
Init()
Service()
important
response
Destroy() -
client request
connection
servlet
servlet
doGet( ) method
HttpServlet
extend
doGet( )
url request
submit
doGet( )
doPost( )
html
import javax.servlet.*;
javax.servlet.http.*;
http servlets
GenericServlet
HttpServlet
request
doGet ( ) doPost ( )
generic
response
response.setContentType("text/html");
getWriter( )
PrintWriter stream
close( )
generate
html
close
Example
}
}
html