SlideShare une entreprise Scribd logo
1  sur  20
Java Programming Skills
By Mr. P. Nagaraju
Programming your passion
14/5/2020
1 Java Programming Skills
Content
⚫Data types
⚫Variables
⚫Operators
⚫Java example programs
⚫Assignment Questions
*
2 Java Programming Skills
Data types
⚫Data types refer to type of data that can be stored in a
variable.
⚫As Java is strongly typed language, you need to define
data type of variable to use it and you can not assign
incompatible data type otherwise the compiler will
give you an error.
*
3 Java Programming Skills
Data types
*
4 Java Programming Skills
Primitive data types
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
*
5 Java Programming Skills
Non-primitive/Reference data types
⚫The non-primitive data types are those data types
which are provided as class by Java API or by class
that you create.
⚫The non-primitive data types include Class, String
Interface, and Array.
⚫String is an example of Reference data types provided
by java. String is an object of the class
java.lang.String.
*
Java Programming Skills
6
//Data type demo program
import java.util.*;
public class Main
{
public static void main(String[] args)
{
int myNum = 5;
float myFloatNum = 9829.33f;
char myLetter = 'D';
boolean myBool = true;
byte myByte = 100;
short myShort = 5000;
long myLong = 2500000;
double myDouble = 9829.23d;
String myText = "Hello";
String[] myBranch = {"CSE", "ECE", "EEE", “CIVIL","MECH"};
*
7 Java Programming Skills
System.out.println("int "+myNum);
System.out.println("float " +myFloatNum);
System.out.println("char "+myLetter);
System.out.println("boolean "+myBool);
System.out.println("byte "+myByte);
System.out.println("short "+myShort);
System.out.println("long "+myLong);
System.out.println("double "+myDouble);
System.out.println("String "+myText);
System.out.println("String array "+Arrays.toString(myBranch));
}// end of main function
} // end of Main Class
*
Java Programming Skills
8
Variables
• These are used to store the values of
elements while the program is executed.
int x=10;
*
9 Java Programming Skills
x
Variables
• These are used to store the values of elements while the
program is executed.
Types of variables
• Local variable
• A Variable which is declared inside a method can be
termed as Local Variable. It is mandatory to initialize local
variable otherwise Compiler will complain about it.
• Instance variable
• A Variable which is declared at class level can be termed
as Instance variable. It is not mandatory to initialize
Instance variable.
• All instance variable will be by default initialized by JVM.
• Static variable
• A Variable which is declared as static is known
as Static variable. Static variables are class level variables.
*
10 Java Programming Skills
Variable Demo Program
public class Main
{
int a; // Instance variable
static int b=20; // static variable
public void prints()
{
int c=10; // local variable
System.out.println("Method local variable: "+c);
}
public static void main(String args[])
{ //Instance and static variable
VariableDemo demo=new VariableDemo();
System.out.println("Instance variable: "+demo.a);
System.out.println("Static variable: "+b);
demo.prints();
}
} *
11 Java Programming Skills
Operators
⚫Operator in Java is a symbol which is used to
perform operations.
⚫Arithmetic Operator,
⚫Shift Operator,
⚫Relational Operator,
⚫Bitwise Operator,
⚫Logical Operator,
⚫Unary operator,
⚫Ternary Operator and
⚫Assignment Operator.
*
Java Programming Skills
12
Operators in Java
*
Java Programming Skills
13
Unary Operator
class Main{
public static void main(String args[])
{
int x=10;
System.out.println(x++); // 10(11)
System.out.println(++x); //12
System.out.println(x--); //12(11)
System.out.println(--x); //10
}
}
*
Java Programming Skills
14
Shift Operators
The left shift operator << is used to shift all of the bits in
a value to the left side of a specified number of times.
The right shift operator >> is used to move left operands
value to right by the number of bits specified by the right
operand.
class Main
{
public static void main(String args[])
{
System.out.println(20<<3); //20*2^3=20*8=160
System.out.println(20>>3); //20/2^3=20/8=2
}
}
*
Java Programming Skills
15
Logical and Bitwise
Class Main{
public static void main(String args[])
{
int a=10,b=5,c=20;
System.out.println(a<b&&a<c);//false&&no checking=false
System.out.println(a<b&a<c);//false&true=false
System.out.println(a>b||a<c);//true||no checking=true
System.out.println(a>b|a<c);//true|true=true
}
}
*
Java Programming Skills
16
Ternary operator
⚫This is used as one liner replacement for if-else
statement. This is the only conditional operator which
takes three operands.
class Main{
public static void main(String args[])
{
int a=12, b=15;
int min=(a<b)?a:b;
System.out.println(min); //12
}
}
*
Java Programming Skills
17
Assignment operator
⚫It is used to assign the value on its right to the
operand on its left.
class Main{
public static void main(String args[]){
int a=10, b=20;
a+=4; //a=a+4(a=10+4)
b-=4; //b=b-4(b=20-4)
System.out.println(a); //14
System.out.println(b); //16
}}
*
Java Programming Skills
18
Assignment Questions
1. Explain Different Data types available in java with a
program?
2. Explain different operators available in java and
write a java program by using unary operators?
3. Define a variable? Write a java program which
demonstrates the types of variables?
*
19 Java Programming Skills
Google form online quiz URL
⚫https://forms.gle/CfqEcf3o91jLEPj89
*
Java Programming Skills
20
Note: Link will be activated from today 1:30pm
and works up to tomorrow 1:00pm

Contenu connexe

Similaire à Java PSkills-session2.pptx

Nitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptxNitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptxshivam460694
 
Computational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptxComputational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptx320126552027SURAKATT
 
In this page, we will learn about the basics of OOPs. Object-Oriented Program...
In this page, we will learn about the basics of OOPs. Object-Oriented Program...In this page, we will learn about the basics of OOPs. Object-Oriented Program...
In this page, we will learn about the basics of OOPs. Object-Oriented Program...Indu32
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction AKR Education
 
Java Intro
Java IntroJava Intro
Java Introbackdoor
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topicsRajesh Verma
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.Tarunsingh198
 
Java Tutorial | My Heart
Java Tutorial | My HeartJava Tutorial | My Heart
Java Tutorial | My HeartBui Kiet
 
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenGraham Royce
 

Similaire à Java PSkills-session2.pptx (20)

Nitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptxNitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptx
 
Computational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptxComputational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptx
 
Core java day1
Core java day1Core java day1
Core java day1
 
In this page, we will learn about the basics of OOPs. Object-Oriented Program...
In this page, we will learn about the basics of OOPs. Object-Oriented Program...In this page, we will learn about the basics of OOPs. Object-Oriented Program...
In this page, we will learn about the basics of OOPs. Object-Oriented Program...
 
Introduction to Java Programming Part 2
Introduction to Java Programming Part 2Introduction to Java Programming Part 2
Introduction to Java Programming Part 2
 
Java basic concept
Java basic conceptJava basic concept
Java basic concept
 
Java tut1
Java tut1Java tut1
Java tut1
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Java
JavaJava
Java
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
 
Java Intro
Java IntroJava Intro
Java Intro
 
Java basic
Java basicJava basic
Java basic
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topics
 
C# 6.0 Preview
C# 6.0 PreviewC# 6.0 Preview
C# 6.0 Preview
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 
Java Tutorial | My Heart
Java Tutorial | My HeartJava Tutorial | My Heart
Java Tutorial | My Heart
 
Java tut1
Java tut1Java tut1
Java tut1
 
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
 

Plus de ssuser99ca78

Introduction-Chapter-1.ppt
Introduction-Chapter-1.pptIntroduction-Chapter-1.ppt
Introduction-Chapter-1.pptssuser99ca78
 
chapter2-(Intelligent Agents).ppt
chapter2-(Intelligent Agents).pptchapter2-(Intelligent Agents).ppt
chapter2-(Intelligent Agents).pptssuser99ca78
 
Java PSkills Session-6 PNR.pptx
Java PSkills Session-6 PNR.pptxJava PSkills Session-6 PNR.pptx
Java PSkills Session-6 PNR.pptxssuser99ca78
 
stringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptxstringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptxssuser99ca78
 
DSP_Course_Contents.ppt
DSP_Course_Contents.pptDSP_Course_Contents.ppt
DSP_Course_Contents.pptssuser99ca78
 
26 Speech Lecture.ppt
26 Speech Lecture.ppt26 Speech Lecture.ppt
26 Speech Lecture.pptssuser99ca78
 
Java PSkills Session-4 PNR.pptx
Java PSkills Session-4 PNR.pptxJava PSkills Session-4 PNR.pptx
Java PSkills Session-4 PNR.pptxssuser99ca78
 
Java PSkills Session-3 PNR.pptx
Java PSkills Session-3 PNR.pptxJava PSkills Session-3 PNR.pptx
Java PSkills Session-3 PNR.pptxssuser99ca78
 

Plus de ssuser99ca78 (13)

chapter3part1.ppt
chapter3part1.pptchapter3part1.ppt
chapter3part1.ppt
 
Introduction-Chapter-1.ppt
Introduction-Chapter-1.pptIntroduction-Chapter-1.ppt
Introduction-Chapter-1.ppt
 
chapter2-(Intelligent Agents).ppt
chapter2-(Intelligent Agents).pptchapter2-(Intelligent Agents).ppt
chapter2-(Intelligent Agents).ppt
 
2.ppt
2.ppt2.ppt
2.ppt
 
Java PSkills Session-6 PNR.pptx
Java PSkills Session-6 PNR.pptxJava PSkills Session-6 PNR.pptx
Java PSkills Session-6 PNR.pptx
 
ARRAYS.ppt
ARRAYS.pptARRAYS.ppt
ARRAYS.ppt
 
stringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptxstringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptx
 
OOPJ.pptx
OOPJ.pptxOOPJ.pptx
OOPJ.pptx
 
DSP_Course_Contents.ppt
DSP_Course_Contents.pptDSP_Course_Contents.ppt
DSP_Course_Contents.ppt
 
26 Speech Lecture.ppt
26 Speech Lecture.ppt26 Speech Lecture.ppt
26 Speech Lecture.ppt
 
Java PSkills Session-4 PNR.pptx
Java PSkills Session-4 PNR.pptxJava PSkills Session-4 PNR.pptx
Java PSkills Session-4 PNR.pptx
 
Java PSkills Session-3 PNR.pptx
Java PSkills Session-3 PNR.pptxJava PSkills Session-3 PNR.pptx
Java PSkills Session-3 PNR.pptx
 
UNIT1-JAVA.pptx
UNIT1-JAVA.pptxUNIT1-JAVA.pptx
UNIT1-JAVA.pptx
 

Dernier

(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 

Dernier (20)

(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 

Java PSkills-session2.pptx

  • 1. Java Programming Skills By Mr. P. Nagaraju Programming your passion 14/5/2020 1 Java Programming Skills
  • 2. Content ⚫Data types ⚫Variables ⚫Operators ⚫Java example programs ⚫Assignment Questions * 2 Java Programming Skills
  • 3. Data types ⚫Data types refer to type of data that can be stored in a variable. ⚫As Java is strongly typed language, you need to define data type of variable to use it and you can not assign incompatible data type otherwise the compiler will give you an error. * 3 Java Programming Skills
  • 4. Data types * 4 Java Programming Skills
  • 5. Primitive data types 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 * 5 Java Programming Skills
  • 6. Non-primitive/Reference data types ⚫The non-primitive data types are those data types which are provided as class by Java API or by class that you create. ⚫The non-primitive data types include Class, String Interface, and Array. ⚫String is an example of Reference data types provided by java. String is an object of the class java.lang.String. * Java Programming Skills 6
  • 7. //Data type demo program import java.util.*; public class Main { public static void main(String[] args) { int myNum = 5; float myFloatNum = 9829.33f; char myLetter = 'D'; boolean myBool = true; byte myByte = 100; short myShort = 5000; long myLong = 2500000; double myDouble = 9829.23d; String myText = "Hello"; String[] myBranch = {"CSE", "ECE", "EEE", “CIVIL","MECH"}; * 7 Java Programming Skills
  • 8. System.out.println("int "+myNum); System.out.println("float " +myFloatNum); System.out.println("char "+myLetter); System.out.println("boolean "+myBool); System.out.println("byte "+myByte); System.out.println("short "+myShort); System.out.println("long "+myLong); System.out.println("double "+myDouble); System.out.println("String "+myText); System.out.println("String array "+Arrays.toString(myBranch)); }// end of main function } // end of Main Class * Java Programming Skills 8
  • 9. Variables • These are used to store the values of elements while the program is executed. int x=10; * 9 Java Programming Skills x
  • 10. Variables • These are used to store the values of elements while the program is executed. Types of variables • Local variable • A Variable which is declared inside a method can be termed as Local Variable. It is mandatory to initialize local variable otherwise Compiler will complain about it. • Instance variable • A Variable which is declared at class level can be termed as Instance variable. It is not mandatory to initialize Instance variable. • All instance variable will be by default initialized by JVM. • Static variable • A Variable which is declared as static is known as Static variable. Static variables are class level variables. * 10 Java Programming Skills
  • 11. Variable Demo Program public class Main { int a; // Instance variable static int b=20; // static variable public void prints() { int c=10; // local variable System.out.println("Method local variable: "+c); } public static void main(String args[]) { //Instance and static variable VariableDemo demo=new VariableDemo(); System.out.println("Instance variable: "+demo.a); System.out.println("Static variable: "+b); demo.prints(); } } * 11 Java Programming Skills
  • 12. Operators ⚫Operator in Java is a symbol which is used to perform operations. ⚫Arithmetic Operator, ⚫Shift Operator, ⚫Relational Operator, ⚫Bitwise Operator, ⚫Logical Operator, ⚫Unary operator, ⚫Ternary Operator and ⚫Assignment Operator. * Java Programming Skills 12
  • 13. Operators in Java * Java Programming Skills 13
  • 14. Unary Operator class Main{ public static void main(String args[]) { int x=10; System.out.println(x++); // 10(11) System.out.println(++x); //12 System.out.println(x--); //12(11) System.out.println(--x); //10 } } * Java Programming Skills 14
  • 15. Shift Operators The left shift operator << is used to shift all of the bits in a value to the left side of a specified number of times. The right shift operator >> is used to move left operands value to right by the number of bits specified by the right operand. class Main { public static void main(String args[]) { System.out.println(20<<3); //20*2^3=20*8=160 System.out.println(20>>3); //20/2^3=20/8=2 } } * Java Programming Skills 15
  • 16. Logical and Bitwise Class Main{ public static void main(String args[]) { int a=10,b=5,c=20; System.out.println(a<b&&a<c);//false&&no checking=false System.out.println(a<b&a<c);//false&true=false System.out.println(a>b||a<c);//true||no checking=true System.out.println(a>b|a<c);//true|true=true } } * Java Programming Skills 16
  • 17. Ternary operator ⚫This is used as one liner replacement for if-else statement. This is the only conditional operator which takes three operands. class Main{ public static void main(String args[]) { int a=12, b=15; int min=(a<b)?a:b; System.out.println(min); //12 } } * Java Programming Skills 17
  • 18. Assignment operator ⚫It is used to assign the value on its right to the operand on its left. class Main{ public static void main(String args[]){ int a=10, b=20; a+=4; //a=a+4(a=10+4) b-=4; //b=b-4(b=20-4) System.out.println(a); //14 System.out.println(b); //16 }} * Java Programming Skills 18
  • 19. Assignment Questions 1. Explain Different Data types available in java with a program? 2. Explain different operators available in java and write a java program by using unary operators? 3. Define a variable? Write a java program which demonstrates the types of variables? * 19 Java Programming Skills
  • 20. Google form online quiz URL ⚫https://forms.gle/CfqEcf3o91jLEPj89 * Java Programming Skills 20 Note: Link will be activated from today 1:30pm and works up to tomorrow 1:00pm