checked exception
Core Java
mahika.a.motwani@gmail.com
Programming Languages
High Level Languages
(Machine independent)
Low-Level Languages
(Machine dependent)
Assembly
language
Machine(Binary
) language
Java
 Java was created by James Gosling at Sun Microsystems (which is now
acquired by Oracle Corporation) and released in 1995.
 Java is a high level, object-oriented programming language.
OOPs Concepts
Encapsulation
Binding (or wrapping) code and data together into a single unit.
A java class is the example of encapsulation.
Abstraction
Hiding internal details and showing functionality only.
With Abstraction
WithoutAbstractio
n
Inheritance
A mechanism by which a class acquires all the properties and behaviours of
an existing class.
Provides code reusability.
Used to achieve runtime polymorphism.
Polymorphism
Ability to take multiple forms.
Example-
int a=10,b=20,c;
c=a+b; //addition
String firstname=“Sachin”, lastname=“Tendulkar”, fullname;
fullname=firstname+lastname;//concatenation
OOPLs
(Four OOPs features)
Partial OOPL Pure OOPL
Fully OOPL
Classes not mandatory.
Data members and methods can
be given outside class.
e.g. C++
Classes mandatory.
Data members and methods
cannot be given outside class.
e.g. Java
Classes mandatory.
Data members and methods
cannot be given outside class.
Primitive data types not
supported.
e.g. Smalltalk
Java supports primitive data types , hence it is a fully OOPL but not pure
OOPL.
int i=20; //primitive type
Integer a=new Integer(20); //Class type
Core Java
Signature of main()
public static void main(String[] args) {
…………..
…………..
}
returnType
methodName(arguments)
{
……
}
void m1()
{
…..
…..
}
int m2()
{
…..
return 2;
}
int m3(int n)
{
…..
return n*n;
}
public static void main(String[] args) {
…………..
…………..
}
class Test
{
public static void myStatic()
{
-----
-----
-----
}
public void myNonStatic()
{
-----
}
}
class Sample
{
public void CallerFunction()
{
// Invoking static function
Test.myStatic();
// Invoking non-static function
Test t= new Test();
t.myNonStatic();
}
}
Invoking Member Funtions Of A Class
class Test
{
public static void main(String[] args)
{
-----
-----
-----
}
}
// Incase of static main()
Test.main();
Invoking main()
Since the main method is static Java virtual Machine can call it without creating
any instance of a class which contains the main method.
// Incase of non-static main()
Test t=new Test()
t.main();
Thank You
Java Code (.java)
JAVAC
Compiler
Byte Code
(.class)
JVM JVM JVM
Linux Mac Windows
JVM
JVM (Java Virtual Machine) is an abstract machine. It is a
specification that provides runtime environment in which java
bytecode can be executed.
JVM is the engine that drives the java code
The JVM performs following main tasks:
 Loads code
 Verifies code
 Executes code
JRE
 JRE is an acronym for Java Runtime Environment.
JRE
JVM
Llibraries
like rt.jar
Other files
JRE
JVM
Llibraries
like rt.jar
Other files
Development
tools like
javac, java
etc.
JDK
JDK
JDK is an acronym for Java Development Kit.
Includes a complete JRE (Java Runtime Environment) plus tools for developing,
debugging, and monitoring Java applications.
Internal Architecture of JVM
Java
Runtim
e
System
Class Loader
Class
Area
Heap Stack
PC
Registe
r
Native
Method
Stack
Execution
engine
Native
Method
Interface
Java
Native
Libraries
Memory areas
allocated by
JVM
Internal Architecture of JVM
Java
Runtim
e
System
Class Loader
Class
Area
Heap Stack
PC
Registe
r
Native
Method
Stack
Execution
engine
Native
Method
Interface
Java
Native
Libraries
Memory areas
allocated by
JVM
Java Keywords
Words that cannot be used as identifiers in programs.
There are 50 java keywords.
All keywords are in lower-case.
Each keyword has special meaning for the compiler.
Keywords that are not used in Java so far are called reserved
words.
Category Keywords
Access modifiers private, protected, public
Class, method,
variable modifiers
abstract, class, extends, final, implements, interface, native,new, st
atic,
strictfp, synchronized, transient, volatile
Flow control break, case, continue, default, do, else, for, if, instanceof,return, swi
tch,
while
Package control import, package
Primitive types boolean, byte, char, double, float, int, long, short
Exception handling assert, catch, finally, throw, throws, try
Enumeration enum
Others super, this, void
Unused const, goto
Points to remember
 const and goto are resevered words.
 true, false and null are literals, not keywords.
List of Java Keywords
Rules for Naming Java Identifiers
Allowed characters for identifiers are[A-Z], [a-z],[0-9], ‘$‘(dollar sign)
and ‘_‘ (underscore).
Should not start with digits(0-9).
Case-sensitive, like id and ID are different.
Java keyword cannot be used as an identifier.
Java Identifiers
Names given to programming elements like variables,
methods, classes, packages and interfaces.
Java Naming conventions
Name Convention
class name should start with uppercase letter and be a noun e.g.Shape, String, Color, System, Thread
etc.
interface name should start with uppercase letter and be an adjective e.g. Runnable, Clonable etc.
method name should start with lowercase letter and be a verb e.g. compute(), print(), println() etc.
variable name should start with lowercase letter e.g. firstName, lastName etc.
package name should be in lowercase letter e.g. java, lang, sql, util etc.
constants name should be in uppercase letter. e.g. BLUE, MAX_PRIORITY etc.
Core Java
Class
 A template that describes the data and behavior.
Object
An entity that has state and behavior is known as an object e.g. chair, bike,
table, car etc.
state: represents data (value) of an object.
behavior: represents the functionality of an object such as deposit,
withdraw etc.
Student
Data
members
id
name
Methods
setId()
setName()
getId()
getName()
class
public class Student {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Java class example
Instantiation/ Object Creation-
Classname referenceVariable=new Classname();
e.g.-
Student s=new Student();
Method Invocation/Call-
Non-static method:
referenceVariable.methodname();
e.g.- s.show();
static method:
Classname.methodname();
e.g.- Sample.display();
Scanner class
A class in java.util package
Used for obtaining the input of the primitive types like int, double etc. and strings
Breaks its input into tokens using a delimiter pattern, which by default matches
whitespace.
To create an object of Scanner class, we usually pass the predefined object System.in,
which represents the standard input stream.
We may pass an object of class File if we want to read input from a file.
Creating instance of Scanner class
To read from System.in:
Scanner sc = new Scanner(System.in);
To read from File:
Scanner sc = new Scanner(new File("myFile"));
Commonly used methods of Scanner class
Method Description
public String next() it returns the next token from the scanner.
public byte nextByte() it scans the next token as a byte.
public short nextShort() it scans the next token as a short value.
public int nextInt() it scans the next token as an int value.
public long nextLong() it scans the next token as a long value.
public float nextFloat() it scans the next token as a float value.
public double nextDouble() it scans the next token as a double value.
Thank You
Types of Variable
local instance static
public class Student
{
int rn; //instance variable
String name; //instance variable
static String college; //static variable
void m1()
{
int l; //local variable
……
}
……….
}
id=1
name= Hriday
Stack
Heap
id=2
name= Anil
s1
s2
college=“SVC”
”
Class Area
class Student{
int id;
String name;
static String college=“SVC”;
………
public static void main(String args[]){
Student s1=new Student();
Student s2=new Student();
…………
}
}
Thank You
Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptx
Data Type Default Value Default size
boolean false 1 bit
char 'u0000' 2 byte
byte 0 1 byte
short 0 2 byte
int 0 4 byte
long 0L 8 byte
float 0.0f 4 byte
double 0.0d 8 byte
lowest unicode value:u0000
highest unicode value:uFFFF
Control Structures
1. Conditional
a) Simple if
b) if–else
c) if-else-if ladder
d) Nested if
e) switch case
2. Looping
a) while loop
b) for loop
c) do while loop
d) for each/enhanced for loop
if Statement:
if(condition){
//code to be executed
}
if –else Statement:
if(condition){
//code if condition is true
}
else{
//code if condition is false
}
if-else-if ladder Statement
if(condition1){
//code to be executed if condition1 is true
}
else if(condition2){
//code to be executed if condition2 is true
}
else if(condition3){
//code to be executed if condition3 is true
}
...
else{
//code to be executed if all the conditions are false
}
Test
Expression 1
Test
Expression 2
Test
Expression 3
No
No
No
Statement
1
Statement
2
Statement
3
else Body
Yes
Yes
Yes
if(Boolean_expression 1)
{
// Executes when the Boolean expression 1 is true
if(Boolean_expression 2)
{
// Executes when the Boolean expression 2 is true
}
}
Nested if
Core Java
Interesting, right?
This is just a sneak preview of the full presentation. We hope you like it! To see the
rest of it, just click here to view it in full on PowerShow.com. Then, if you’d like, you
can also log in to PowerShow.com to download the entire presentation for free.

More Related Content

PPTX
Core Java Tutorials by Mahika Tutorials
PDF
Basic Java Programming
DOCX
Computer Programming 2
PPTX
1_JavIntro
PPT
Oop java
PPT
Core_java_ppt.ppt
DOCX
javaopps concepts
PPTX
Let's start with Java- Basic Concepts
Core Java Tutorials by Mahika Tutorials
Basic Java Programming
Computer Programming 2
1_JavIntro
Oop java
Core_java_ppt.ppt
javaopps concepts
Let's start with Java- Basic Concepts

Similar to Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptx (20)

PDF
Java essentials for hadoop
PDF
Java essentials for hadoop
PPT
Java Intro
PDF
Java Interview Questions PDF By ScholarHat
PPTX
DAY_1.1.pptx
PDF
Object Oriented Programming with Java Basic Syntax.pdf
PPT
JAVA_INTRODUCTION- History, Constructor, Inheritance
PPTX
Java For Automation
PPTX
Object Oriented Programming unit 1 content for students
PPTX
Module 1.pptx
PPTX
Oop2010 Scala Presentation Stal
PPTX
Java OOP Concepts 1st Slide
PDF
Java basic concept
PPT
JAVA_INTRODUCTION- History, Constructor, Inheritance
PPTX
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
PPTX
Std 12 Computer Chapter 7 Java Basics (Part 1)
PDF
Java programming basics
PDF
A seminar report on core java
PPTX
Computational Problem Solving 016 (1).pptx
PPTX
Java essentials for hadoop
Java essentials for hadoop
Java Intro
Java Interview Questions PDF By ScholarHat
DAY_1.1.pptx
Object Oriented Programming with Java Basic Syntax.pdf
JAVA_INTRODUCTION- History, Constructor, Inheritance
Java For Automation
Object Oriented Programming unit 1 content for students
Module 1.pptx
Oop2010 Scala Presentation Stal
Java OOP Concepts 1st Slide
Java basic concept
JAVA_INTRODUCTION- History, Constructor, Inheritance
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
Std 12 Computer Chapter 7 Java Basics (Part 1)
Java programming basics
A seminar report on core java
Computational Problem Solving 016 (1).pptx
Ad

More from NagarathnaRajur2 (20)

PPT
Basics of C (2).ppt bbbbbbbbbbbbbbbbbbbbb
PPT
C-Programming Chapter 1 Fundamentals of C.ppt
PPT
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
PPT
C-Programming Chapter 1 Fundamentals of C.ppt
PPT
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
PPTX
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
PPTX
EXCEPTIONS-PYTHON.pptx RUNTIME ERRORS HANDLING
PPTX
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
PPTX
ppt on arm memory.pptx yjjghjghjjjjjjjj
PPTX
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
PPT
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
PPTX
8051 programes -ppt.pptx bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
PPTX
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
PPT
MEMORY.ppt 8051/8052 MEMORY MANEGEMENT MEMORY DESCRIPTION
PPTX
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
PPTX
review.pptx mnbmnbm,nb,n,nm,mn,mn,n,nm,
PPTX
IOT introduction with applications ffffffffffffffffffffff
PPTX
CORE JAVA PPT FOR ENGINEERS BBBBBBBBBBBBBBBBBBB
PPTX
JAVA CLASS PPT FOR ENGINEERING STUDENTS BBBBBBBBBBBBBBBBBBB
PPTX
JavaSteps. PPT NBNBVNBNVBNNNNNNNNNNNNNN
Basics of C (2).ppt bbbbbbbbbbbbbbbbbbbbb
C-Programming Chapter 1 Fundamentals of C.ppt
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
C-Programming Chapter 1 Fundamentals of C.ppt
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
EXCEPTIONS-PYTHON.pptx RUNTIME ERRORS HANDLING
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
ppt on arm memory.pptx yjjghjghjjjjjjjj
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
8051 programes -ppt.pptx bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
MEMORY.ppt 8051/8052 MEMORY MANEGEMENT MEMORY DESCRIPTION
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
review.pptx mnbmnbm,nb,n,nm,mn,mn,n,nm,
IOT introduction with applications ffffffffffffffffffffff
CORE JAVA PPT FOR ENGINEERS BBBBBBBBBBBBBBBBBBB
JAVA CLASS PPT FOR ENGINEERING STUDENTS BBBBBBBBBBBBBBBBBBB
JavaSteps. PPT NBNBVNBNVBNNNNNNNNNNNNNN
Ad

Recently uploaded (20)

PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
PPTX
Module on health assessment of CHN. pptx
PDF
Race Reva University – Shaping Future Leaders in Artificial Intelligence
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
Journal of Dental Science - UDMY (2020).pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
PPTX
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
Climate and Adaptation MCQs class 7 from chatgpt
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
IP : I ; Unit I : Preformulation Studies
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
Module on health assessment of CHN. pptx
Race Reva University – Shaping Future Leaders in Artificial Intelligence
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
Introduction to pro and eukaryotes and differences.pptx
Journal of Dental Science - UDMY (2020).pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
B.Sc. DS Unit 2 Software Engineering.pptx
Climate and Adaptation MCQs class 7 from chatgpt
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
IP : I ; Unit I : Preformulation Studies
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Environmental Education MCQ BD2EE - Share Source.pdf

Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptx

  • 2. mahika.a.motwani@gmail.com Programming Languages High Level Languages (Machine independent) Low-Level Languages (Machine dependent) Assembly language Machine(Binary ) language
  • 3. Java  Java was created by James Gosling at Sun Microsystems (which is now acquired by Oracle Corporation) and released in 1995.  Java is a high level, object-oriented programming language.
  • 5. Encapsulation Binding (or wrapping) code and data together into a single unit. A java class is the example of encapsulation.
  • 6. Abstraction Hiding internal details and showing functionality only. With Abstraction WithoutAbstractio n
  • 7. Inheritance A mechanism by which a class acquires all the properties and behaviours of an existing class. Provides code reusability. Used to achieve runtime polymorphism.
  • 8. Polymorphism Ability to take multiple forms. Example- int a=10,b=20,c; c=a+b; //addition String firstname=“Sachin”, lastname=“Tendulkar”, fullname; fullname=firstname+lastname;//concatenation
  • 9. OOPLs (Four OOPs features) Partial OOPL Pure OOPL Fully OOPL Classes not mandatory. Data members and methods can be given outside class. e.g. C++ Classes mandatory. Data members and methods cannot be given outside class. e.g. Java Classes mandatory. Data members and methods cannot be given outside class. Primitive data types not supported. e.g. Smalltalk Java supports primitive data types , hence it is a fully OOPL but not pure OOPL. int i=20; //primitive type Integer a=new Integer(20); //Class type
  • 12. public static void main(String[] args) { ………….. ………….. }
  • 14. public static void main(String[] args) { ………….. ………….. }
  • 15. class Test { public static void myStatic() { ----- ----- ----- } public void myNonStatic() { ----- } } class Sample { public void CallerFunction() { // Invoking static function Test.myStatic(); // Invoking non-static function Test t= new Test(); t.myNonStatic(); } } Invoking Member Funtions Of A Class
  • 16. class Test { public static void main(String[] args) { ----- ----- ----- } } // Incase of static main() Test.main(); Invoking main() Since the main method is static Java virtual Machine can call it without creating any instance of a class which contains the main method. // Incase of non-static main() Test t=new Test() t.main();
  • 18. Java Code (.java) JAVAC Compiler Byte Code (.class) JVM JVM JVM Linux Mac Windows
  • 19. JVM JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed. JVM is the engine that drives the java code The JVM performs following main tasks:  Loads code  Verifies code  Executes code
  • 20. JRE  JRE is an acronym for Java Runtime Environment. JRE JVM Llibraries like rt.jar Other files
  • 21. JRE JVM Llibraries like rt.jar Other files Development tools like javac, java etc. JDK JDK JDK is an acronym for Java Development Kit. Includes a complete JRE (Java Runtime Environment) plus tools for developing, debugging, and monitoring Java applications.
  • 22. Internal Architecture of JVM Java Runtim e System Class Loader Class Area Heap Stack PC Registe r Native Method Stack Execution engine Native Method Interface Java Native Libraries Memory areas allocated by JVM
  • 23. Internal Architecture of JVM Java Runtim e System Class Loader Class Area Heap Stack PC Registe r Native Method Stack Execution engine Native Method Interface Java Native Libraries Memory areas allocated by JVM
  • 24. Java Keywords Words that cannot be used as identifiers in programs. There are 50 java keywords. All keywords are in lower-case. Each keyword has special meaning for the compiler. Keywords that are not used in Java so far are called reserved words.
  • 25. Category Keywords Access modifiers private, protected, public Class, method, variable modifiers abstract, class, extends, final, implements, interface, native,new, st atic, strictfp, synchronized, transient, volatile Flow control break, case, continue, default, do, else, for, if, instanceof,return, swi tch, while Package control import, package Primitive types boolean, byte, char, double, float, int, long, short Exception handling assert, catch, finally, throw, throws, try Enumeration enum Others super, this, void Unused const, goto Points to remember  const and goto are resevered words.  true, false and null are literals, not keywords. List of Java Keywords
  • 26. Rules for Naming Java Identifiers Allowed characters for identifiers are[A-Z], [a-z],[0-9], ‘$‘(dollar sign) and ‘_‘ (underscore). Should not start with digits(0-9). Case-sensitive, like id and ID are different. Java keyword cannot be used as an identifier. Java Identifiers Names given to programming elements like variables, methods, classes, packages and interfaces.
  • 27. Java Naming conventions Name Convention class name should start with uppercase letter and be a noun e.g.Shape, String, Color, System, Thread etc. interface name should start with uppercase letter and be an adjective e.g. Runnable, Clonable etc. method name should start with lowercase letter and be a verb e.g. compute(), print(), println() etc. variable name should start with lowercase letter e.g. firstName, lastName etc. package name should be in lowercase letter e.g. java, lang, sql, util etc. constants name should be in uppercase letter. e.g. BLUE, MAX_PRIORITY etc.
  • 29. Class  A template that describes the data and behavior. Object An entity that has state and behavior is known as an object e.g. chair, bike, table, car etc. state: represents data (value) of an object. behavior: represents the functionality of an object such as deposit, withdraw etc.
  • 31. public class Student { private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } Java class example
  • 32. Instantiation/ Object Creation- Classname referenceVariable=new Classname(); e.g.- Student s=new Student(); Method Invocation/Call- Non-static method: referenceVariable.methodname(); e.g.- s.show(); static method: Classname.methodname(); e.g.- Sample.display();
  • 33. Scanner class A class in java.util package Used for obtaining the input of the primitive types like int, double etc. and strings Breaks its input into tokens using a delimiter pattern, which by default matches whitespace. To create an object of Scanner class, we usually pass the predefined object System.in, which represents the standard input stream. We may pass an object of class File if we want to read input from a file.
  • 34. Creating instance of Scanner class To read from System.in: Scanner sc = new Scanner(System.in); To read from File: Scanner sc = new Scanner(new File("myFile"));
  • 35. Commonly used methods of Scanner class Method Description public String next() it returns the next token from the scanner. public byte nextByte() it scans the next token as a byte. public short nextShort() it scans the next token as a short value. public int nextInt() it scans the next token as an int value. public long nextLong() it scans the next token as a long value. public float nextFloat() it scans the next token as a float value. public double nextDouble() it scans the next token as a double value.
  • 37. Types of Variable local instance static
  • 38. public class Student { int rn; //instance variable String name; //instance variable static String college; //static variable void m1() { int l; //local variable …… } ………. }
  • 39. id=1 name= Hriday Stack Heap id=2 name= Anil s1 s2 college=“SVC” ” Class Area class Student{ int id; String name; static String college=“SVC”; ……… public static void main(String args[]){ Student s1=new Student(); Student s2=new Student(); ………… } }
  • 42. Data Type Default Value Default size boolean false 1 bit char 'u0000' 2 byte byte 0 1 byte short 0 2 byte int 0 4 byte long 0L 8 byte float 0.0f 4 byte double 0.0d 8 byte lowest unicode value:u0000 highest unicode value:uFFFF
  • 43. Control Structures 1. Conditional a) Simple if b) if–else c) if-else-if ladder d) Nested if e) switch case 2. Looping a) while loop b) for loop c) do while loop d) for each/enhanced for loop
  • 45. if –else Statement: if(condition){ //code if condition is true } else{ //code if condition is false }
  • 46. if-else-if ladder Statement if(condition1){ //code to be executed if condition1 is true } else if(condition2){ //code to be executed if condition2 is true } else if(condition3){ //code to be executed if condition3 is true } ... else{ //code to be executed if all the conditions are false } Test Expression 1 Test Expression 2 Test Expression 3 No No No Statement 1 Statement 2 Statement 3 else Body Yes Yes Yes
  • 47. if(Boolean_expression 1) { // Executes when the Boolean expression 1 is true if(Boolean_expression 2) { // Executes when the Boolean expression 2 is true } } Nested if
  • 49. Interesting, right? This is just a sneak preview of the full presentation. We hope you like it! To see the rest of it, just click here to view it in full on PowerShow.com. Then, if you’d like, you can also log in to PowerShow.com to download the entire presentation for free.