SlideShare a Scribd company logo
1 of 25
Chapter 7
Java Basics
(Part 1)
Presented by nuzhat memon
Presented by Nuzhat Memon
Introduction to Java
 Java is an object-oriented programming language
developed at Sun Microsystems, a company a best
known for its high-end Unix workstations, in 1991.
 Modeled after c++, the java language was designed to
be small, simple, fast, efficient and portable across
platform and operating systems.
 Java is considered as one of the ideal language for
distributing executable programs via the WWW and also
general purpose programming language for developing
programs that are easily usable and portable across
different platforms.
2
1991
Small
Efficient
fast
Portable
Simple
Bytecode
(Class file)
Windows
JVM
Linux
JVM
MAc
JVM
Presented by Nuzhat Memon
Introduction to Java (continue) | JDK
 JDK is used to develop and run Java program
 Java includes a set of class libraries that provide basic data types, system
input and output capabilities, and other utility functions.
 These Basic classes are part of the Java Development Kit (JDK).
 JDK has classes to support networking, common internet protocols and user
interface toolkit functions.
3
Class libraries
Basic data types,
System input & output capabilities
and other utility functions
Development
tools
JDK (Java Development Kit)
Compiler
Presented by Nuzhat Memon
Java is Platform Indedpendent
 Platform independence is a program’s capability of being moved easily from one
computer system to another.
 Java is platform independent at both the source and the binary level..
 At the source level, java’s primitive data types have consistent sizes across all
development platforms.
 At binary level, platform independence is possible due to bytecode interpreter.
4
Bytecode
(Class file)
Windows
JVM
Linux
JVM
MAc
JVM
Presented by Nuzhat Memon 5
LINUX JVM
Windows JVM
Java Platform Independent
Java
source code
(*.java)
Java
compiler
(javac)
Java
bytecode
(*.class)
JVM - Java
Interpreter
(java)
HelloWorld.java After compilation HelloWorld.class
(class file is our
bytecode)
JVM understand
only bytecode
MAC JVM
Presented by Nuzhat Memon
JVM (Java Virtual Machine) | Bytecode
 Program written in java are compiled into machine language for a computer that
doesn’t really exist. This is so-called “virtual” computer is known as the Java Virtual
Machine (JVM).
 The machine language for the java virtual machine is called java bytecode.
 Different java bytecode interpreter is needed for each type of computer.
 Advantage - Platform independent - Java binary files are actually in a form
called bytecodes that is not specific to any one processor or any operating
system.
 The only disadvantage of using bytecodes is its slow execution speed.
 There are tools available to convert java bytecodes into native code. Native code is
faster to execute, but then it does not remain machine independent.
6
Compiler
Faster Execution Speed
Platform Dependent
Interpreter
Slow Execution Speed
Platform Independent
JVM Java Bytecode
Presented by Nuzhat Memon
Which of the following is missing from compilation process to
execute java application ?
7
JVM - Java Interpreter(Java)
Java Compiler (Javac)
Java Source File (usually have
extension.java)
When we create a Java Program File, we usually save it as
filename.java which is called source code
And then we will Compile our source code using the
java compiler javac
Compiler will translate the whole program into machine
language known as bytecode in java and creates a file
with extension .class
Java Interpreter or JVM will read the bytecode line by
line and Run the class file on different OS or hardware
Java Bytecode file (*.class)
When java program created java source file using text
editor, which file extension should be given? .java
When the program gets compiled without error, compiler
creates a file with which extension ?.class
By using which extension file java interpreter bytecode
executes? java
Which of the following way user can run “abc.java”
source program through the application using java
interpreter? Java abc
To compile the java program we have to type what in
front of source filename? javac filename.java
Presented by Nuzhat Memon
Create Java application using SciTE editor
 Start SciTE application.
 Select File  New and type the java program.
 To save the file, select File Save with filename.java
 Compile source program using Tools Compile (Ctrl+F7)
 If the program is compiled without any error, execute it using
Tools  Go (F5)
8
Presented by Nuzhat Memon
Structure Of A Java Program
+ In Java program, text in angle bracket < and > is used as a place holder.
+ Java consists of function header and the sequence of statements enclosed
between braces { and }
public class <class-name>
{
<optional – variable – declarations – and –methods>
public static void main(String [ ] args)
{
<statements>
}
<optional – variable – declarations – and – methods>
}
Java source file & class name must be same
System.out.print() and System.out.println() both methods are used to display results
9
Presented by Nuzhat Memon
Overview
10
byte age = 10
short number = 20
int count = 30
long area = 1234567
float pi = 3.14
double rate = 100.75
char ch = ‘n’
boolean Check = true
Data Type Variable Literal
Expression
A + B * C
//Comments
Presented by Nuzhat Memon
Data Types
+ Java supports 8 primitive data types.
+ Data Types – byte (1 byte), short (2 bytes), int (4 bytes), long (8 bytes),
float (4 bytes), double (8 bytes), char (2 bytes), Boolean (1 byte)
11
byte, short, int, long Integer Store integer value
float, double Float Store floating point value
Char Character Single Unicode character
boolean Boolean Store true/false logical value
Presented by Nuzhat Memon 12
Data type
numbers character
2 bytes
char c=‘A’
integers
Eg 17,-38488,0
byte
1 byte
short
2 bytes
int
4 bytes
long
8 bytes
long num=4l
real numbers
Eg 5.8 ,-129.35, 3.14
Real numbers in Java are
compliant with IEEE 754
float
4 bytes
float Pi=3.14f
double
8 bytes
double var=0.1234567
boolean
1 byte
boolean b=true
I
n
t
e
g
e
r
byte 1 -128 to 127
short
2
-32768 to
32767
int
4
-2147483648
to 2147483647
long
8
-263 to 263-1
R
e
a
l
float
4
Upto 7
significant
digits
double
8
Upto 15
significant
digits
char 2
16 bit unicode
character
boolean 1
True , false
Default value
is false
(default data type of
floating point literal)
Signed values : -2 b-1-1 to 2 b-1 -2 b-1 to 2 b-1-1
Unsigned values: 0 to 2 b-1 0 to 2 b-1 -1
byte :
-2 8-1 to 2 8-1-1
-2 7 to 2 7-1
-128 to 127
short :
-2 16-1 to 2 16-1-1
-2 15 to 2 15-1
-32768 to 32767
int :
-2 32-1 to 2 32-1-1
-2 31to 2 31-1
-2147483648 to
2147483647
long:
-2 64-1 to 2 64-1-1
-2 63 to 2 63-1
-9223372036854775808
to 9223372036854775807
char :
0 to 2 16-1-1
0 to 215-1
0 to 65535
boolean:
True, false
Presented by Nuzhat Memon
Variable
+ A name used to refer to the data stored in memory is called a variable
+ Syntax <datatype-name> {variable-names};
+ Example int marks; | float rate; | char grade;
RULES TO DEFINE VARIABLE NAME
• It must begin with an alphabet, underscore (_) or dollar sign ($).
• No spaces are allowed in variables : birth date, my school project
• It cannot be a reserved word : class, public, static,void if etc
• Legal variable names : birth_date, result, CallCost, top5students, date, $price
• Illegal variable names : 4me, %discount, birth date
13
Presented by Nuzhat Memon
Guidelines For Naming Variables
+ Choose meaningful variable names. (calculateArea, calculateCallCost)
+ Java allows variable name of any length.
+ Separate words with underscore. Ex : birth_date
+ Java is case-sensitive. So upper case and lower case are considered to
be different. Example variable X is different from the variable x and
a nuzhat is not a Nuzhat or NUZHAT.
+ Names of classes to begin with upper case.
+ Names of variables and of methods begin with lower case. Referred to
as camel case. Ex : birthDate, callCost
14
Presented by Nuzhat Memon
Variable Types
There are 3 kinds of variables :
1) Instance variables
2) Class/Static variables
3) Local variables
15
class Demo{
public static void main(String args[]){
int age=15;
float pi=3.14;
static int count=0;
void display(){
int total=50;
System.out.println(“Hello”);
}
}
}
Instance variables
local variable
Class variable
Presented by Nuzhat Memon
Literals- A name used for a constant value is known as literal. Different
kinds of literals in java for number, character, string and boolean values.
16
Numeric Literals Boolean Literals
True and False
default value is False
Character Literals
16-bit Unicode characters
enclosed in ‘ ‘
Example ‘a’, ‘#’, ‘3’
String Literals
sequence of characters
enclosed in “”
Example “hello”,
Literals
Integer literals
Whole numbers
Real number literal
Floating point literals
standard
12.37
scientific
0.1237 x 102
0.1237e2
Escape character :
n : New Line
t : Tab
f : Form Feed
b : Backspace
r : Carriage return
decimal
Base 10
(0 to 9)
75,75L,-75
octal
Base 8
(0 to 7)
075
hexadecimal
Base 16
(0 to 9, A to F)
0x45 or 0X45
Unicode
integer
literals
u000
ufff
Binary
number
Digits 0 or 1
0b or 0B
Presented by Nuzhat Memon
Comments
Comments in a program are for human readers only
Comments are entirely ignored by the computer. They are not compiled or interpreted
in java
Java supports 3 types of comments :
1) Single line comment //
All the text up to the end of the line is ignored.
2) Multi line comment /* ..... */
Comments cannot be nested (comment inside a comment)
3) Documentation comment /** ..... */
(creating API documentation from the code, javadoc system)
17
Presented by Nuzhat Memon
Expression
+ The basic building blocks of expressions are literals, variables and function calls.
+ More complex expressions can be built up by using operators to combine simpler
expression.
+ Operators include arithmetic operators (+, -, *, /, %), comparison operators (>, <, =,
…), logical operators (and, or, not…)
A + B * C (A + B) * C
18
Presented by Nuzhat Memon
calculate simple and compound interest
class CalculateInterest
{
public static void main(String args[])
{
double p=10000;
double r=4.5;
double n=10;
double si,ci;
si = (p*r*n)/100;
ci= si + p;
System.out.println(“Simple interest is “ + si);
System.out.println(“Compound interest is “ + ci);
}
}
19
1)Save the file as CalculateInterest.java on desktop
2) Open command prompt and type
cd desktop
javac CalculateInterest.java
java CalculateInterest
Presented by Nuzhat Memon
Operators
+ Operators are special symbols used to build an expression.
20
Operators
1.
Arithmetic
Operators
2.
Comparison
operators
3. Logical
Operators
4,
Conditional
operators
5,
Assignment
operator
Presented by Nuzhat Memon 21
Basic arithmetic
operators are +, – ,
* , / , % (Modulus)
All these operators are
binary, they take 2
operands.
Used for byte, short,
int, long, float, double
Arithmetic Operators
Operator Meaning Eg
+ Addition 2+8
– Subtraction 2-8
* Multiplication 2*8
/ Division 8/2
% Reminder 8%3
++ is increment
operator, which
adds 1.
-- is decrement
operator, which
subtracts 1.
Increment/Decrement
Operators
++x
pre-increment
x++
post-increment
--x
pre-decrement
x-- post-decrement
Comparison
operators are
known as
relational
operators.
Comparison Operators
Operator Meaning
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
== Equal to
!= Not equal to
Logical operators
known as boolean
operators.
Logical operators :
AND, OR, XOR
(Exclusive OR),
NOT
Operator Sign Use
AND && Used to combine two
values – AND
OR || Used to combine two
values – OR
XOR ^ It returns true only if
operands are different
NOT ! Operant is true, result
is false & vice versa
Also known as ternary
operator.
Conditional operator
uses 3 operands.
It uses two symbols ?
and : in the expression.
Syntax : (boolean-expr)
? (expr1) : (expr2)
To assign a value
to variable by
using the
assignment
operator ‘=’
Syntax:
<variable> =
<expression>;
Conditional
Operator
Operators
Arithmetic
Operator
Increment and
Decrement
Operator
Comparison
Operator
Logical
Operator
Assignment
Operator
Presented by Nuzhat Memon
Looping
Java supports 3 types of looping constructs:
(1) for loop
+ Entry controlled or pre-test loop constructs.
+ for loop are executed if condition is true.
+ It is used when numbers of iterations are pre-defined.
(2) while loop
+ Entry controlled or pre-test loop constructs.
+ Loop are executed if condition is true.
+ It is used when number of iterations are not pre-determined.
(3) do...while loop
+ Exit controlled or post-test loop constructs.
+ It repeats the loop if the test condition is true.
+ Here, statements of loop are executed at least once.
22
Presented by Nuzhat Memon
Statement
(1) IF STATEMENT
+ Used in a program to take one of two alternative coursed of action,
depending upon Boolean valued expression.
(2) SWITCH STATEMENT
+ Used when there are many alternative actions to be taken depending
upon the value of a variable or expression.
+ Test expression should be of the type byte, char, short or int or enum
23
Presented by Nuzhat Memon
Statement
BREAK STATEMENT
+ Used to transfer the control outside switch/loop structure.
+ It is used to exit the loop.
+ It is jumps outside the nearest loop containing this statement.
CONTINUE STATEMENT
+ It is used to skip the following statement in a loop and continue
with the next iteration.
24
Presented by Nuzhat Memon
Thanks!
Any questions?
You can find me at:
+ nuzhatmemon.com
+ Nuzhat.memon@gmail.com
25

More Related Content

What's hot

Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - ObjectsWebStackAcademy
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic FunctionsWebStackAcademy
 
Std 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqsStd 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqsNuzhat Memon
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript ProgrammingSehwan Noh
 
Form using html and java script validation
Form using html and java script validationForm using html and java script validation
Form using html and java script validationMaitree Patel
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state managementpriya Nithya
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSSAmit Tyagi
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScriptShahDhruv21
 

What's hot (20)

Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Java script
Java scriptJava script
Java script
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript: Events Handling
JavaScript: Events HandlingJavaScript: Events Handling
JavaScript: Events Handling
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
 
Std 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqsStd 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqs
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Form using html and java script validation
Form using html and java script validationForm using html and java script validation
Form using html and java script validation
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
jQuery
jQueryjQuery
jQuery
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Html forms
Html formsHtml forms
Html forms
 
Javascript
JavascriptJavascript
Javascript
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basics
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Javascript
JavascriptJavascript
Javascript
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 

Similar to Std 12 Computer Chapter 7 Java Basics (Part 1)

College Project - Java Disassembler - Description
College Project - Java Disassembler - DescriptionCollege Project - Java Disassembler - Description
College Project - Java Disassembler - DescriptionGanesh Samarthyam
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slidesunny khan
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsMahika Tutorials
 
Full CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java languageFull CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java languagessuser2963071
 
Java (1).ppt seminar topics engineering
Java (1).ppt  seminar topics engineeringJava (1).ppt  seminar topics engineering
Java (1).ppt seminar topics engineering4MU21CS023
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java MayaTofik
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introductionchnrketan
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with javaTechglyphs
 
2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopment2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopmentCarlosPineda729332
 
Computational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptxComputational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptx320126552027SURAKATT
 

Similar to Std 12 Computer Chapter 7 Java Basics (Part 1) (20)

Core Java
Core JavaCore Java
Core Java
 
OOP-Chap2.docx
OOP-Chap2.docxOOP-Chap2.docx
OOP-Chap2.docx
 
College Project - Java Disassembler - Description
College Project - Java Disassembler - DescriptionCollege Project - Java Disassembler - Description
College Project - Java Disassembler - Description
 
Class 8 - Java.pptx
Class 8 - Java.pptxClass 8 - Java.pptx
Class 8 - Java.pptx
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
 
Unit 1
Unit 1Unit 1
Unit 1
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
Full CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java languageFull CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java language
 
Java (1).ppt seminar topics engineering
Java (1).ppt  seminar topics engineeringJava (1).ppt  seminar topics engineering
Java (1).ppt seminar topics engineering
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java
 
basic_java.ppt
basic_java.pptbasic_java.ppt
basic_java.ppt
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
 
Hello java
Hello java   Hello java
Hello java
 
Hello Java-First Level
Hello Java-First LevelHello Java-First Level
Hello Java-First Level
 
Hello java
Hello java  Hello java
Hello java
 
Core java part1
Core java  part1Core java  part1
Core java part1
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
 
2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopment2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopment
 
Computational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptxComputational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptx
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 

More from Nuzhat Memon

Std 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQsStd 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQsNuzhat Memon
 
Std 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQsStd 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQsNuzhat Memon
 
Std 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQsStd 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQsNuzhat Memon
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsNuzhat Memon
 
Std 12 computer chapter 6 object oriented concepts (part 2)
Std 12 computer chapter 6 object oriented concepts (part 2)Std 12 computer chapter 6 object oriented concepts (part 2)
Std 12 computer chapter 6 object oriented concepts (part 2)Nuzhat Memon
 
Std 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structureStd 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structureNuzhat Memon
 
Std 12 Computer Chapter 7 Java Basics (Part 2)
Std 12 Computer Chapter 7 Java Basics (Part 2)Std 12 Computer Chapter 7 Java Basics (Part 2)
Std 12 Computer Chapter 7 Java Basics (Part 2)Nuzhat Memon
 
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQsStd 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQsNuzhat Memon
 
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQsStd 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQsNuzhat Memon
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Nuzhat Memon
 
Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)Nuzhat Memon
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Nuzhat Memon
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingNuzhat Memon
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...Nuzhat Memon
 
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)Nuzhat Memon
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...Nuzhat Memon
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...Nuzhat Memon
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...Nuzhat Memon
 
Std 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to LayersStd 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to LayersNuzhat Memon
 
Std 11 Computer Chapter 3 Creating Animation using Synfig (Part 3) [practica...
Std 11 Computer Chapter 3  Creating Animation using Synfig (Part 3) [practica...Std 11 Computer Chapter 3  Creating Animation using Synfig (Part 3) [practica...
Std 11 Computer Chapter 3 Creating Animation using Synfig (Part 3) [practica...Nuzhat Memon
 

More from Nuzhat Memon (20)

Std 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQsStd 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQs
 
Std 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQsStd 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQs
 
Std 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQsStd 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQs
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQs
 
Std 12 computer chapter 6 object oriented concepts (part 2)
Std 12 computer chapter 6 object oriented concepts (part 2)Std 12 computer chapter 6 object oriented concepts (part 2)
Std 12 computer chapter 6 object oriented concepts (part 2)
 
Std 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structureStd 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structure
 
Std 12 Computer Chapter 7 Java Basics (Part 2)
Std 12 Computer Chapter 7 Java Basics (Part 2)Std 12 Computer Chapter 7 Java Basics (Part 2)
Std 12 Computer Chapter 7 Java Basics (Part 2)
 
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQsStd 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
 
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQsStd 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)
 
Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
 
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
 
Std 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to LayersStd 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to Layers
 
Std 11 Computer Chapter 3 Creating Animation using Synfig (Part 3) [practica...
Std 11 Computer Chapter 3  Creating Animation using Synfig (Part 3) [practica...Std 11 Computer Chapter 3  Creating Animation using Synfig (Part 3) [practica...
Std 11 Computer Chapter 3 Creating Animation using Synfig (Part 3) [practica...
 

Recently uploaded

Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spiritegoetzinger
 
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办fqiuho152
 
fca-bsps-decision-letter-redacted (1).pdf
fca-bsps-decision-letter-redacted (1).pdffca-bsps-decision-letter-redacted (1).pdf
fca-bsps-decision-letter-redacted (1).pdfHenry Tapper
 
government_intervention_in_business_ownership[1].pdf
government_intervention_in_business_ownership[1].pdfgovernment_intervention_in_business_ownership[1].pdf
government_intervention_in_business_ownership[1].pdfshaunmashale756
 
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...Henry Tapper
 
call girls in Nand Nagri (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in  Nand Nagri (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in  Nand Nagri (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Nand Nagri (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service NashikHigh Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance CompanyInterimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance CompanyTyöeläkeyhtiö Elo
 
Attachment Of Assets......................
Attachment Of Assets......................Attachment Of Assets......................
Attachment Of Assets......................AmanBajaj36
 
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsHigh Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
SBP-Market-Operations and market managment
SBP-Market-Operations and market managmentSBP-Market-Operations and market managment
SBP-Market-Operations and market managmentfactical
 
Quantitative Analysis of Retail Sector Companies
Quantitative Analysis of Retail Sector CompaniesQuantitative Analysis of Retail Sector Companies
Quantitative Analysis of Retail Sector Companiesprashantbhati354
 
VIP Call Girls Service Begumpet Hyderabad Call +91-8250192130
VIP Call Girls Service Begumpet Hyderabad Call +91-8250192130VIP Call Girls Service Begumpet Hyderabad Call +91-8250192130
VIP Call Girls Service Begumpet Hyderabad Call +91-8250192130Suhani Kapoor
 
Classical Theory of Macroeconomics by Adam Smith
Classical Theory of Macroeconomics by Adam SmithClassical Theory of Macroeconomics by Adam Smith
Classical Theory of Macroeconomics by Adam SmithAdamYassin2
 
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...Suhani Kapoor
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Roomdivyansh0kumar0
 
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spirit
 
🔝+919953056974 🔝young Delhi Escort service Pusa Road
🔝+919953056974 🔝young Delhi Escort service Pusa Road🔝+919953056974 🔝young Delhi Escort service Pusa Road
🔝+919953056974 🔝young Delhi Escort service Pusa Road
 
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
 
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
 
fca-bsps-decision-letter-redacted (1).pdf
fca-bsps-decision-letter-redacted (1).pdffca-bsps-decision-letter-redacted (1).pdf
fca-bsps-decision-letter-redacted (1).pdf
 
government_intervention_in_business_ownership[1].pdf
government_intervention_in_business_ownership[1].pdfgovernment_intervention_in_business_ownership[1].pdf
government_intervention_in_business_ownership[1].pdf
 
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
 
call girls in Nand Nagri (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in  Nand Nagri (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in  Nand Nagri (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Nand Nagri (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service NashikHigh Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
 
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance CompanyInterimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
 
Attachment Of Assets......................
Attachment Of Assets......................Attachment Of Assets......................
Attachment Of Assets......................
 
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsHigh Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
SBP-Market-Operations and market managment
SBP-Market-Operations and market managmentSBP-Market-Operations and market managment
SBP-Market-Operations and market managment
 
Quantitative Analysis of Retail Sector Companies
Quantitative Analysis of Retail Sector CompaniesQuantitative Analysis of Retail Sector Companies
Quantitative Analysis of Retail Sector Companies
 
VIP Call Girls Service Begumpet Hyderabad Call +91-8250192130
VIP Call Girls Service Begumpet Hyderabad Call +91-8250192130VIP Call Girls Service Begumpet Hyderabad Call +91-8250192130
VIP Call Girls Service Begumpet Hyderabad Call +91-8250192130
 
Classical Theory of Macroeconomics by Adam Smith
Classical Theory of Macroeconomics by Adam SmithClassical Theory of Macroeconomics by Adam Smith
Classical Theory of Macroeconomics by Adam Smith
 
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
 
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

Std 12 Computer Chapter 7 Java Basics (Part 1)

  • 1. Chapter 7 Java Basics (Part 1) Presented by nuzhat memon
  • 2. Presented by Nuzhat Memon Introduction to Java  Java is an object-oriented programming language developed at Sun Microsystems, a company a best known for its high-end Unix workstations, in 1991.  Modeled after c++, the java language was designed to be small, simple, fast, efficient and portable across platform and operating systems.  Java is considered as one of the ideal language for distributing executable programs via the WWW and also general purpose programming language for developing programs that are easily usable and portable across different platforms. 2 1991 Small Efficient fast Portable Simple Bytecode (Class file) Windows JVM Linux JVM MAc JVM
  • 3. Presented by Nuzhat Memon Introduction to Java (continue) | JDK  JDK is used to develop and run Java program  Java includes a set of class libraries that provide basic data types, system input and output capabilities, and other utility functions.  These Basic classes are part of the Java Development Kit (JDK).  JDK has classes to support networking, common internet protocols and user interface toolkit functions. 3 Class libraries Basic data types, System input & output capabilities and other utility functions Development tools JDK (Java Development Kit) Compiler
  • 4. Presented by Nuzhat Memon Java is Platform Indedpendent  Platform independence is a program’s capability of being moved easily from one computer system to another.  Java is platform independent at both the source and the binary level..  At the source level, java’s primitive data types have consistent sizes across all development platforms.  At binary level, platform independence is possible due to bytecode interpreter. 4 Bytecode (Class file) Windows JVM Linux JVM MAc JVM
  • 5. Presented by Nuzhat Memon 5 LINUX JVM Windows JVM Java Platform Independent Java source code (*.java) Java compiler (javac) Java bytecode (*.class) JVM - Java Interpreter (java) HelloWorld.java After compilation HelloWorld.class (class file is our bytecode) JVM understand only bytecode MAC JVM
  • 6. Presented by Nuzhat Memon JVM (Java Virtual Machine) | Bytecode  Program written in java are compiled into machine language for a computer that doesn’t really exist. This is so-called “virtual” computer is known as the Java Virtual Machine (JVM).  The machine language for the java virtual machine is called java bytecode.  Different java bytecode interpreter is needed for each type of computer.  Advantage - Platform independent - Java binary files are actually in a form called bytecodes that is not specific to any one processor or any operating system.  The only disadvantage of using bytecodes is its slow execution speed.  There are tools available to convert java bytecodes into native code. Native code is faster to execute, but then it does not remain machine independent. 6 Compiler Faster Execution Speed Platform Dependent Interpreter Slow Execution Speed Platform Independent JVM Java Bytecode
  • 7. Presented by Nuzhat Memon Which of the following is missing from compilation process to execute java application ? 7 JVM - Java Interpreter(Java) Java Compiler (Javac) Java Source File (usually have extension.java) When we create a Java Program File, we usually save it as filename.java which is called source code And then we will Compile our source code using the java compiler javac Compiler will translate the whole program into machine language known as bytecode in java and creates a file with extension .class Java Interpreter or JVM will read the bytecode line by line and Run the class file on different OS or hardware Java Bytecode file (*.class) When java program created java source file using text editor, which file extension should be given? .java When the program gets compiled without error, compiler creates a file with which extension ?.class By using which extension file java interpreter bytecode executes? java Which of the following way user can run “abc.java” source program through the application using java interpreter? Java abc To compile the java program we have to type what in front of source filename? javac filename.java
  • 8. Presented by Nuzhat Memon Create Java application using SciTE editor  Start SciTE application.  Select File  New and type the java program.  To save the file, select File Save with filename.java  Compile source program using Tools Compile (Ctrl+F7)  If the program is compiled without any error, execute it using Tools  Go (F5) 8
  • 9. Presented by Nuzhat Memon Structure Of A Java Program + In Java program, text in angle bracket < and > is used as a place holder. + Java consists of function header and the sequence of statements enclosed between braces { and } public class <class-name> { <optional – variable – declarations – and –methods> public static void main(String [ ] args) { <statements> } <optional – variable – declarations – and – methods> } Java source file & class name must be same System.out.print() and System.out.println() both methods are used to display results 9
  • 10. Presented by Nuzhat Memon Overview 10 byte age = 10 short number = 20 int count = 30 long area = 1234567 float pi = 3.14 double rate = 100.75 char ch = ‘n’ boolean Check = true Data Type Variable Literal Expression A + B * C //Comments
  • 11. Presented by Nuzhat Memon Data Types + Java supports 8 primitive data types. + Data Types – byte (1 byte), short (2 bytes), int (4 bytes), long (8 bytes), float (4 bytes), double (8 bytes), char (2 bytes), Boolean (1 byte) 11 byte, short, int, long Integer Store integer value float, double Float Store floating point value Char Character Single Unicode character boolean Boolean Store true/false logical value
  • 12. Presented by Nuzhat Memon 12 Data type numbers character 2 bytes char c=‘A’ integers Eg 17,-38488,0 byte 1 byte short 2 bytes int 4 bytes long 8 bytes long num=4l real numbers Eg 5.8 ,-129.35, 3.14 Real numbers in Java are compliant with IEEE 754 float 4 bytes float Pi=3.14f double 8 bytes double var=0.1234567 boolean 1 byte boolean b=true I n t e g e r byte 1 -128 to 127 short 2 -32768 to 32767 int 4 -2147483648 to 2147483647 long 8 -263 to 263-1 R e a l float 4 Upto 7 significant digits double 8 Upto 15 significant digits char 2 16 bit unicode character boolean 1 True , false Default value is false (default data type of floating point literal) Signed values : -2 b-1-1 to 2 b-1 -2 b-1 to 2 b-1-1 Unsigned values: 0 to 2 b-1 0 to 2 b-1 -1 byte : -2 8-1 to 2 8-1-1 -2 7 to 2 7-1 -128 to 127 short : -2 16-1 to 2 16-1-1 -2 15 to 2 15-1 -32768 to 32767 int : -2 32-1 to 2 32-1-1 -2 31to 2 31-1 -2147483648 to 2147483647 long: -2 64-1 to 2 64-1-1 -2 63 to 2 63-1 -9223372036854775808 to 9223372036854775807 char : 0 to 2 16-1-1 0 to 215-1 0 to 65535 boolean: True, false
  • 13. Presented by Nuzhat Memon Variable + A name used to refer to the data stored in memory is called a variable + Syntax <datatype-name> {variable-names}; + Example int marks; | float rate; | char grade; RULES TO DEFINE VARIABLE NAME • It must begin with an alphabet, underscore (_) or dollar sign ($). • No spaces are allowed in variables : birth date, my school project • It cannot be a reserved word : class, public, static,void if etc • Legal variable names : birth_date, result, CallCost, top5students, date, $price • Illegal variable names : 4me, %discount, birth date 13
  • 14. Presented by Nuzhat Memon Guidelines For Naming Variables + Choose meaningful variable names. (calculateArea, calculateCallCost) + Java allows variable name of any length. + Separate words with underscore. Ex : birth_date + Java is case-sensitive. So upper case and lower case are considered to be different. Example variable X is different from the variable x and a nuzhat is not a Nuzhat or NUZHAT. + Names of classes to begin with upper case. + Names of variables and of methods begin with lower case. Referred to as camel case. Ex : birthDate, callCost 14
  • 15. Presented by Nuzhat Memon Variable Types There are 3 kinds of variables : 1) Instance variables 2) Class/Static variables 3) Local variables 15 class Demo{ public static void main(String args[]){ int age=15; float pi=3.14; static int count=0; void display(){ int total=50; System.out.println(“Hello”); } } } Instance variables local variable Class variable
  • 16. Presented by Nuzhat Memon Literals- A name used for a constant value is known as literal. Different kinds of literals in java for number, character, string and boolean values. 16 Numeric Literals Boolean Literals True and False default value is False Character Literals 16-bit Unicode characters enclosed in ‘ ‘ Example ‘a’, ‘#’, ‘3’ String Literals sequence of characters enclosed in “” Example “hello”, Literals Integer literals Whole numbers Real number literal Floating point literals standard 12.37 scientific 0.1237 x 102 0.1237e2 Escape character : n : New Line t : Tab f : Form Feed b : Backspace r : Carriage return decimal Base 10 (0 to 9) 75,75L,-75 octal Base 8 (0 to 7) 075 hexadecimal Base 16 (0 to 9, A to F) 0x45 or 0X45 Unicode integer literals u000 ufff Binary number Digits 0 or 1 0b or 0B
  • 17. Presented by Nuzhat Memon Comments Comments in a program are for human readers only Comments are entirely ignored by the computer. They are not compiled or interpreted in java Java supports 3 types of comments : 1) Single line comment // All the text up to the end of the line is ignored. 2) Multi line comment /* ..... */ Comments cannot be nested (comment inside a comment) 3) Documentation comment /** ..... */ (creating API documentation from the code, javadoc system) 17
  • 18. Presented by Nuzhat Memon Expression + The basic building blocks of expressions are literals, variables and function calls. + More complex expressions can be built up by using operators to combine simpler expression. + Operators include arithmetic operators (+, -, *, /, %), comparison operators (>, <, =, …), logical operators (and, or, not…) A + B * C (A + B) * C 18
  • 19. Presented by Nuzhat Memon calculate simple and compound interest class CalculateInterest { public static void main(String args[]) { double p=10000; double r=4.5; double n=10; double si,ci; si = (p*r*n)/100; ci= si + p; System.out.println(“Simple interest is “ + si); System.out.println(“Compound interest is “ + ci); } } 19 1)Save the file as CalculateInterest.java on desktop 2) Open command prompt and type cd desktop javac CalculateInterest.java java CalculateInterest
  • 20. Presented by Nuzhat Memon Operators + Operators are special symbols used to build an expression. 20 Operators 1. Arithmetic Operators 2. Comparison operators 3. Logical Operators 4, Conditional operators 5, Assignment operator
  • 21. Presented by Nuzhat Memon 21 Basic arithmetic operators are +, – , * , / , % (Modulus) All these operators are binary, they take 2 operands. Used for byte, short, int, long, float, double Arithmetic Operators Operator Meaning Eg + Addition 2+8 – Subtraction 2-8 * Multiplication 2*8 / Division 8/2 % Reminder 8%3 ++ is increment operator, which adds 1. -- is decrement operator, which subtracts 1. Increment/Decrement Operators ++x pre-increment x++ post-increment --x pre-decrement x-- post-decrement Comparison operators are known as relational operators. Comparison Operators Operator Meaning > Greater than < Less than >= Greater than or equal to <= Less than or equal to == Equal to != Not equal to Logical operators known as boolean operators. Logical operators : AND, OR, XOR (Exclusive OR), NOT Operator Sign Use AND && Used to combine two values – AND OR || Used to combine two values – OR XOR ^ It returns true only if operands are different NOT ! Operant is true, result is false & vice versa Also known as ternary operator. Conditional operator uses 3 operands. It uses two symbols ? and : in the expression. Syntax : (boolean-expr) ? (expr1) : (expr2) To assign a value to variable by using the assignment operator ‘=’ Syntax: <variable> = <expression>; Conditional Operator Operators Arithmetic Operator Increment and Decrement Operator Comparison Operator Logical Operator Assignment Operator
  • 22. Presented by Nuzhat Memon Looping Java supports 3 types of looping constructs: (1) for loop + Entry controlled or pre-test loop constructs. + for loop are executed if condition is true. + It is used when numbers of iterations are pre-defined. (2) while loop + Entry controlled or pre-test loop constructs. + Loop are executed if condition is true. + It is used when number of iterations are not pre-determined. (3) do...while loop + Exit controlled or post-test loop constructs. + It repeats the loop if the test condition is true. + Here, statements of loop are executed at least once. 22
  • 23. Presented by Nuzhat Memon Statement (1) IF STATEMENT + Used in a program to take one of two alternative coursed of action, depending upon Boolean valued expression. (2) SWITCH STATEMENT + Used when there are many alternative actions to be taken depending upon the value of a variable or expression. + Test expression should be of the type byte, char, short or int or enum 23
  • 24. Presented by Nuzhat Memon Statement BREAK STATEMENT + Used to transfer the control outside switch/loop structure. + It is used to exit the loop. + It is jumps outside the nearest loop containing this statement. CONTINUE STATEMENT + It is used to skip the following statement in a loop and continue with the next iteration. 24
  • 25. Presented by Nuzhat Memon Thanks! Any questions? You can find me at: + nuzhatmemon.com + Nuzhat.memon@gmail.com 25