Docsity

Java notes- chapter 1 to10, Study notes of Java Programming

Toggle sidebar
bg1
Programming Paradigms
Programming Paradigm is style of programming away of
thinking about software construction It does not refer
to aspecific language but rather to away to program
amethodology Some languages make it easy to write in
some pavidigms but not others
Structured Programming
emphasis is on functionality not on data
Does not support jumping from one instruction to other
with statements like goto jump etc
Statements executed in serial or structured manner
Imperative Paradigm
Based on Von Neumann Architecture
Program describe steps that changes
the state of the computer
ParallelProcessing
Parallel Processing Processing of program instructions
by dividing them among multiple processors
Declarative Programming focuses on what needs to be
done rather than how It provides abstraction
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Java notes- chapter 1 to10 and more Study notes Java Programming in PDF only on Docsity!

Programming Paradigms

Programming Paradigm is^ style of^ programming a^ way of

thinking about^ software^ construction^ It^ does^ not^ refer

to a^ specific language but^ rather to a way to program

a (^) methodology Some (^) languages make it (^) easy to (^) write in

some pavidigms but not others

Structured Programming

emphasis

is (^) on

functionality not^ on^ data

Does not^ support jumping from^ one^ instruction^ to^ other

with statements like goto jump etc

Statements executed in serial^ or^ structured manner

Imperative Paradigm

Based on Von^ Neumann Architecture

Program describe^ steps that^ changes

the state of the computer

ParallelProcessing

Parallel Processing Processing of program instructions

by dividing them^ among multiple processors

Declarative Programming focuses^ on^ what^ needs to^ be

done rather than how It provides abstraction

Examples of Procedural Programming Paradigms

C Developed by Dennis Ritchi

and Ken (^) Thompson

Ctt Developed by Bjarne

Stvoustrup

Java Developed by James

Gosling at^ Sun^ Microsystems

Coldfusion (^) Developed (^) by

JJ Allaire

Pascal Developed by Niklaus

Wirth

Class method

class Example E

int (^) age void (^) printAged E

g

z Print (^) age Enammpiendolinerampiec (^01) printAge 3

In inheritance child class can access the properties

and methods^ of^ its^ parent class

Class DoronCar^ extends^ Car

String engineSize^200

Inheritance

bool has^ SixGears^ true

s

void main C E

class ar E^ Doroncar CI DoroncarC

int (^) maxspeed (^) print 2 enginesize String color String owner^ I^ print 2 color

A (^) create an

example of^ inheritance

public

static void main^ string args

I (^) b b

can be Can be accessed^ Command^ Line

accessed (^) outside (^) without (^) creating (^) Arguments

the class^ object^ of^ the^ class

System out^ printIn L L class (^) After class (^) name out is^ like a name if (^) there is^ a^ dot i static reference we are^ accessing a^ static variable^ it^ islike member of^ that (^) class a^ pointer whichis

referring to^ a^ objet

float I^3 in^ f

int y X (^11) narrowing conversion error int y

int ni 11 no error

float 3 SI (^) narrowing conversion^ euro

because it's a double value

by default

float f 3 Sf 11 no error

Classes and^ Objects

class

class is like creating a^ datatype

Description of^ object's^ properties^ and^ behaviour

Object

Real world^ entity Instance of^ a^ class Instance member

Consumes memory to^ hold property values

variables 4 functions

class Box E

private int^ length^ breadth^ height^ T

public

void setDimensionC^ int l int b int h E

length L

breadth bi height h

public void^ showDimension^ C^ E

System out^ printh L^ L^ length

System out^ printIn^ C^ B^ t^ breadth

System out^ printIn^ C^ H^ t^ heights

class Example E

public static^

void (^) main (^) StringCT (^) avg.DE

Box b2 new Box S

bi setDimensionC^12 10,

bi showDimensionC

bi new Box^ C^ i^11 now b1^ is^ pointing to new^ object

bishowDimension^ previous object^ will be handled^ by

garbage collector (^11) It will

print

0,0 O

Primitive data^ types in^ Java^ dont^ let make^ Jada^ a

tool OOP^ based (^) language

Variables made with int char float are^ not objects

Solution wrapper class

There is

wrapper

class for^ every primitive data type

Integer isas^ Integer value Ofc^123

Double d1 Double^ value^ of^ C^3 1a^3 I

Integer

is

Integer

value Ofc 1100110 2 i

Keeps number^ in

int a Integer pause Intl 123 binary Win stove

double b Double pauseDouble D u g

decimal (^) equivalent

int c^ is.int Value i

t

Access modifiers in Java

In Ctt if we do^ not mention the access modifier

by

default it is

private In^ Java^

it is^ default Only public

class can be used in^ other packages

In one Java file only one class can be public

In a^ package there^ can^ be multiple public classes^ but

we have to create saperate Java file for each public class

Constructors

Member function of^ class

name of constructor is same as (^) class name

No return

type public class^ Box^

E

private int^ e^ b^ hi

public

Box E

l lo

b 8

y

h e

publig.bg

CintL.intD.inttDs 8

H IYohafetfjh

public static^ void^ main^ string angs^

E

Box b2^ new BoxC

Box bz^ new^ Box^ 10,20^30 i

Used to initialized newly created^ object

When there^ is^ no constructor^ is defined compile

implicitly provide^ a^ default^ constructor^ for^ the^ class

Constructor can^ be^ parameterized

Constructors can be overloaded