SlideShare une entreprise Scribd logo
1  sur  24
Java Programming Skills
by Mr. P. Nagaraju
Programming your passion
14/5/2020
1 Java Programming Skills
Frequently missed questions in
Quiz-2
*
Java Programming Skills
2
Question Correct
String s1 = "Hello"; s1.concat("Java");
System.out.println(s1);
Correct answer:- Hello
43 / 90
Which one is a valid declaration of a boolean?
Correct answer:- boolean b=false;
41 / 90
What is the output of following code: (Types of Variables)
Correct answer:- 5 0 20.0
21 / 90
Write the o/p for the following code? (invalid Syntax)
Correct answer:- Compile time error
39 / 90
String s1 = new String("Java "); s1.concat(" Core ");
s1 = s1.concat(" Programming");
Correct answer:- Java Programming
42 / 90
Content
⚫Operators
⚫Java example programs
*
3 Java Programming Skills
Operators in Java
Operator is a symbol which is used to perform operations on
one or more operands to produce a result.
⚫Arithmetic Operator,
⚫Relational Operator,
⚫Bitwise Operator,
⚫Logical Operator,
⚫Unary operator,
⚫Ternary Operator
⚫Assignment Operator
*
Java Programming Skills
4
Operators in Java
*
Java Programming Skills
5
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
6
Arithmetic Operator
public class ArithmeticOp
{ public static void main(String args[])
{ int num1 = 100, num2 = 20;
System.out.println("num1 + num2: " + (num1 +
num2) ); System.out.println("num1 - num2: " +
(num1 - num2) ); System.out.println("num1 * num2:
" + (num1 * num2) ); System.out.println("num1 /
num2: " + (num1 / num2) );
System.out.println("num1 % num2: " + (num1 %
num2) );
}
} *
Java Programming Skills
7
Bitwise 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. Left shift by 1 is equivalent to a
multiplication by 2.
• The right shift operators >>(signed) and >>>
(unsigned) are used to move left operands value to
right by the number of bits specified by the right
operand. Right shift by 1 is equivalent to a division
by 2.
*
Java Programming Skills
8
Bitwise Shift operators
*
Java Programming Skills
9
Bitwise Shift operators
*
Java Programming Skills
10
25*22
10/22
Bitwise Operators
⚫Bitwise operator performs bit by bit processing.
⚫num1 = 11; /* equal to 00001011*/
num2 = 22; /* equal to 00010110 */
⚫num1 & num2 compares corresponding bits of
num1 and num2 and generates 1 if both bits are
equal, else it returns 0. In our case it would return: 2
which is 00000010 because in the binary form of
num1 and num2 only second last bits are matching.
⚫num1 | num2 compares corresponding bits of num1
and num2 and generates 1 if either bit is 1, else it
returns 0. In our case it would return 31 which is
00011111 *
Java Programming Skills
11
Bitwise Operators
⚫num1 ^ num2 compares corresponding bits of
num1 and num2 and generates 1 if they are not
equal, else it returns 0. In our example it would
return 29 which is equivalent to 00011101
⚫~num1 is a complement operator that just
changes the bit from 0 to 1 and 1 to 0. In our
example it would return -12 which is signed 8 bit
equivalent to 11110100
*
Java Programming Skills
12
Bitwise operators
public class BitwiseOp
{ public static void main(String args[])
{ int num1 = 11; // 11 = 00001011
int num2 = 22; //22 = 00010110
System.out.println(num1 & num2); //2
System.out.println(num1 | num2); //31
System.out.println(num1 ^ num2); //29
System.out.println(~num1); //-12
}
}
*
Java Programming Skills
13
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
14
Relational / Comparison Operators
public class Main
{
public static void main(String[] args)
{ int a=10,b=10;
System.out.println(a==b); //true
System.out.println(a!=b); //false
System.out.println(a>b); //false
System.out.println(a<b); //false
System.out.println(a>=b); //true
System.out.println(a<=b); //true
}
}
*
Java Programming Skills
15
Logical Operators
public class LogicalOperatorDemo {
public static void main(String args[]) {
boolean b1 = true;
boolean b2 = false;
System.out.println("b1&&b2 " + (b1&&b2)); //false
System.out.println("b1||b2 " + (b1||b2)); //true
System.out.println("!(b1&&b2) " + !(b1&&b2));//true
}
}
*
Java Programming Skills
16
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
17
instanceof
⚫instanceof operator is used to test whether the object
is an instance of the specified type (class or subclass or
interface).
⚫The instanceof in java is also known as
type comparison operator because it compares the
instance with type. It returns either true or false. If we
apply the instanceof operator with any variable that has
null value, it returns false.
*
Java Programming Skills
18
Instanceof operator example1
public class Main
{
public static void main (String[]args)
{
Main s=new Main();
Main s1=null;
System.out.println(s instanceof Main);//true
System.out.println(s1 instanceof Main);//false
System.out.println(s); //address of s
System.out.println(s1); //address of s1 is null
}
}
*
Java Programming Skills
19
Instanceof operator example2
class Main
{
public static void main (String[] args)
{
String name = "Programiz";
Integer age = 22;
int a=22;
System.out.println(name instanceof String)); //true
System.out.println((Integer)a instanceof Integer)); //true
}
}
*
Java Programming Skills
20
Control Statements
⚫control statements are used to control the flow of
execution of a program.
⚫Java control statements can be put into the following
three categories: selection, iteration, and jump.
⮚The selection statements allow program to choose a
different path of execution based on a condition.
⮚Iteration statements allow program execution to
repeat one or more statements.
⮚Jump statements transfer the control to other parts of
the program.
*
Java Programming Skills
21
*
Java Programming Skills
22
Assignment Questions
1. Explain in detail about the different types of
operators available in java.
2. Write a java program to implement assignment,
unary, relational, and ternary operators?
3. Explain in detail about the bitwise operators with an
suitable program?
*
23 Java Programming Skills
Quiz-3 Google form URL
⚫https://forms.gle/BcgQF8XgjJD3GvFV8
*
Java Programming Skills
24

Contenu connexe

Similaire à Java PSkills Session-3 PNR.pptx

Java if and else
Java if and elseJava if and else
Java if and elsepratik8897
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statementsCtOlaf
 
chap 2 : Operators and Assignments (scjp/ocjp)
chap 2 : Operators and Assignments (scjp/ocjp)chap 2 : Operators and Assignments (scjp/ocjp)
chap 2 : Operators and Assignments (scjp/ocjp)It Academy
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01Abdul Samee
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01Abdul Samee
 
Chapter 3:Programming with Java Operators and Strings
Chapter 3:Programming with Java Operators and  StringsChapter 3:Programming with Java Operators and  Strings
Chapter 3:Programming with Java Operators and StringsIt Academy
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7REHAN IJAZ
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statementsIntro C# Book
 
Python tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingPython tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingRahul Tandale
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressionsStoian Kirov
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golangwww.ixxo.io
 
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
 
Core Java introduction | Basics | free course
Core Java introduction | Basics | free course Core Java introduction | Basics | free course
Core Java introduction | Basics | free course Kernel Training
 
Chapter 3 : Programming with Java Operators and Strings
Chapter 3 : Programming with Java Operators and  StringsChapter 3 : Programming with Java Operators and  Strings
Chapter 3 : Programming with Java Operators and StringsIt Academy
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3Ibrahim Reda
 

Similaire à Java PSkills Session-3 PNR.pptx (20)

Java if and else
Java if and elseJava if and else
Java if and else
 
00_Introduction to Java.ppt
00_Introduction to Java.ppt00_Introduction to Java.ppt
00_Introduction to Java.ppt
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
 
chap 2 : Operators and Assignments (scjp/ocjp)
chap 2 : Operators and Assignments (scjp/ocjp)chap 2 : Operators and Assignments (scjp/ocjp)
chap 2 : Operators and Assignments (scjp/ocjp)
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01
 
Chapter 3:Programming with Java Operators and Strings
Chapter 3:Programming with Java Operators and  StringsChapter 3:Programming with Java Operators and  Strings
Chapter 3:Programming with Java Operators and Strings
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statements
 
Python tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingPython tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online Training
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
 
Basic commands in C++
Basic commands in C++Basic commands in C++
Basic commands in C++
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golang
 
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)
 
Core Java introduction | Basics | free course
Core Java introduction | Basics | free course Core Java introduction | Basics | free course
Core Java introduction | Basics | free course
 
Chapter 3 : Programming with Java Operators and Strings
Chapter 3 : Programming with Java Operators and  StringsChapter 3 : Programming with Java Operators and  Strings
Chapter 3 : Programming with Java Operators and Strings
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Week 4
Week 4Week 4
Week 4
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
 

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
 
Java PSkills-session2.pptx
Java PSkills-session2.pptxJava PSkills-session2.pptx
Java PSkills-session2.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
 

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
 
Java PSkills-session2.pptx
Java PSkills-session2.pptxJava PSkills-session2.pptx
Java PSkills-session2.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
 
UNIT1-JAVA.pptx
UNIT1-JAVA.pptxUNIT1-JAVA.pptx
UNIT1-JAVA.pptx
 

Dernier

Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksMagic Marks
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stageAbc194748
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxnuruddin69
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 

Dernier (20)

Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 

Java PSkills Session-3 PNR.pptx

  • 1. Java Programming Skills by Mr. P. Nagaraju Programming your passion 14/5/2020 1 Java Programming Skills
  • 2. Frequently missed questions in Quiz-2 * Java Programming Skills 2 Question Correct String s1 = "Hello"; s1.concat("Java"); System.out.println(s1); Correct answer:- Hello 43 / 90 Which one is a valid declaration of a boolean? Correct answer:- boolean b=false; 41 / 90 What is the output of following code: (Types of Variables) Correct answer:- 5 0 20.0 21 / 90 Write the o/p for the following code? (invalid Syntax) Correct answer:- Compile time error 39 / 90 String s1 = new String("Java "); s1.concat(" Core "); s1 = s1.concat(" Programming"); Correct answer:- Java Programming 42 / 90
  • 4. Operators in Java Operator is a symbol which is used to perform operations on one or more operands to produce a result. ⚫Arithmetic Operator, ⚫Relational Operator, ⚫Bitwise Operator, ⚫Logical Operator, ⚫Unary operator, ⚫Ternary Operator ⚫Assignment Operator * Java Programming Skills 4
  • 5. Operators in Java * Java Programming Skills 5
  • 6. 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 6
  • 7. Arithmetic Operator public class ArithmeticOp { public static void main(String args[]) { int num1 = 100, num2 = 20; System.out.println("num1 + num2: " + (num1 + num2) ); System.out.println("num1 - num2: " + (num1 - num2) ); System.out.println("num1 * num2: " + (num1 * num2) ); System.out.println("num1 / num2: " + (num1 / num2) ); System.out.println("num1 % num2: " + (num1 % num2) ); } } * Java Programming Skills 7
  • 8. Bitwise 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. Left shift by 1 is equivalent to a multiplication by 2. • The right shift operators >>(signed) and >>> (unsigned) are used to move left operands value to right by the number of bits specified by the right operand. Right shift by 1 is equivalent to a division by 2. * Java Programming Skills 8
  • 9. Bitwise Shift operators * Java Programming Skills 9
  • 10. Bitwise Shift operators * Java Programming Skills 10 25*22 10/22
  • 11. Bitwise Operators ⚫Bitwise operator performs bit by bit processing. ⚫num1 = 11; /* equal to 00001011*/ num2 = 22; /* equal to 00010110 */ ⚫num1 & num2 compares corresponding bits of num1 and num2 and generates 1 if both bits are equal, else it returns 0. In our case it would return: 2 which is 00000010 because in the binary form of num1 and num2 only second last bits are matching. ⚫num1 | num2 compares corresponding bits of num1 and num2 and generates 1 if either bit is 1, else it returns 0. In our case it would return 31 which is 00011111 * Java Programming Skills 11
  • 12. Bitwise Operators ⚫num1 ^ num2 compares corresponding bits of num1 and num2 and generates 1 if they are not equal, else it returns 0. In our example it would return 29 which is equivalent to 00011101 ⚫~num1 is a complement operator that just changes the bit from 0 to 1 and 1 to 0. In our example it would return -12 which is signed 8 bit equivalent to 11110100 * Java Programming Skills 12
  • 13. Bitwise operators public class BitwiseOp { public static void main(String args[]) { int num1 = 11; // 11 = 00001011 int num2 = 22; //22 = 00010110 System.out.println(num1 & num2); //2 System.out.println(num1 | num2); //31 System.out.println(num1 ^ num2); //29 System.out.println(~num1); //-12 } } * Java Programming Skills 13
  • 14. 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 14
  • 15. Relational / Comparison Operators public class Main { public static void main(String[] args) { int a=10,b=10; System.out.println(a==b); //true System.out.println(a!=b); //false System.out.println(a>b); //false System.out.println(a<b); //false System.out.println(a>=b); //true System.out.println(a<=b); //true } } * Java Programming Skills 15
  • 16. Logical Operators public class LogicalOperatorDemo { public static void main(String args[]) { boolean b1 = true; boolean b2 = false; System.out.println("b1&&b2 " + (b1&&b2)); //false System.out.println("b1||b2 " + (b1||b2)); //true System.out.println("!(b1&&b2) " + !(b1&&b2));//true } } * Java Programming Skills 16
  • 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 17
  • 18. instanceof ⚫instanceof operator is used to test whether the object is an instance of the specified type (class or subclass or interface). ⚫The instanceof in java is also known as type comparison operator because it compares the instance with type. It returns either true or false. If we apply the instanceof operator with any variable that has null value, it returns false. * Java Programming Skills 18
  • 19. Instanceof operator example1 public class Main { public static void main (String[]args) { Main s=new Main(); Main s1=null; System.out.println(s instanceof Main);//true System.out.println(s1 instanceof Main);//false System.out.println(s); //address of s System.out.println(s1); //address of s1 is null } } * Java Programming Skills 19
  • 20. Instanceof operator example2 class Main { public static void main (String[] args) { String name = "Programiz"; Integer age = 22; int a=22; System.out.println(name instanceof String)); //true System.out.println((Integer)a instanceof Integer)); //true } } * Java Programming Skills 20
  • 21. Control Statements ⚫control statements are used to control the flow of execution of a program. ⚫Java control statements can be put into the following three categories: selection, iteration, and jump. ⮚The selection statements allow program to choose a different path of execution based on a condition. ⮚Iteration statements allow program execution to repeat one or more statements. ⮚Jump statements transfer the control to other parts of the program. * Java Programming Skills 21
  • 23. Assignment Questions 1. Explain in detail about the different types of operators available in java. 2. Write a java program to implement assignment, unary, relational, and ternary operators? 3. Explain in detail about the bitwise operators with an suitable program? * 23 Java Programming Skills
  • 24. Quiz-3 Google form URL ⚫https://forms.gle/BcgQF8XgjJD3GvFV8 * Java Programming Skills 24