Introduction Java
Introduction Java
for
beginners
Scope
Java language fundamentals
concepts of classes and inheritance
Packages & Interfaces
Exception handling
Applet programming
String handling
Three important packages: lang, I/o, util
Basics of JDBC
Eventhandling, AWT & Swing
Thursday, December Java Programming 2
9, 2021
What we will not cover….
Multithreaded programming
Java Networking
Bean programming
Rest of the packages than the three
mentioned .
Knowledge of programming.
Knowledge of C Language basics.
Fundamental concepts of OOP
Desire to learn
Originally named "Oak" , renamed to "JAVA" in
1995 and announced to public.
Java uses unicode to represent characters.
The width of storage for a character is 16 bits.
String is a separate class in Java and it is not a
primitive data type.
Boolean takes values either true or false
Note/Caution : Boolean do not map to numbers as
in C.
Thursday, December Java Programming 23
9, 2021
Type Casting
Java is strictly type cast
Rules:
byte and short are promoted to int
if one operand is long, then entire expression is
promoted to long
if one is float, then then entire expression is
promoted to float
if one is double, then entire expression is
promoted to double
P r o g r a m m in g
P r o c e s s -O r ie n te d O b je c t-O r ie n te d
c o d e a c tin g o n d a ta d a ta c o n tr o llin g a c c e s s to c o d e
! ?
do something. This is the essence of
OOP.
Polymorphism
mymethod(...);
simple:
myobject.mymethod(...);
static class method:
myclass.classmethod(...);
create an object, then invoke a method on it:
(new myclass(...)).mymethod;
myobject.methodreturninghisobject(..).hismethod(..);
Here’s a specific example of the last form:
String s;
double d;
s = “43.4”;
d = Double.valueOf(s).doubleValue(); // set d to
43.4
int i, j;
if (i = j) ... /* i = j is an int, not boolean */
The + and += operators have been overloaded for strings -
concatenating as in BASIC. Note that operator overloading, as
implemented in C++, is not available.
int i[];
i = new int[10];
creates an array of 10 integers, indices run from 0 to 9. You can of
course create arrays of any class.
int i[];
int j;
...
j = i.length;
length is not a method, but a “predefined” instance variable
this and super
A subclass inherits the methods of its super class.
When a subclass overrides such methods, it’s often
necessary to invoke the equivalent method in the
parent class and the keyword super lets you do
this:
Button b;
MyButton mb;// where MyButton extends Button
jdb debugger
<html>
<head>
<title>Dave's Jumping Button</title> </head>
<body>
Public
instance
variables
Private
methods
move()