SlideShare a Scribd company logo
1 of 42
WELCOME
Core Java
Installation
Environment setup:
• Install JDK
• Install eclipse
JVM, JRE, JDK
First java program
First Java Program
public class MyClass{
public static void main(String[] args){
System.out.println(“Hello baabtra”);
}
}
Compile the program
->javac MyClass.java
Run it
->java MyClass
The process
Features of Java
Naming convention
Java follows camelcase syntax for naming
Type Convention
Class Should start with uppercase letter and be a noun e.g. String,
Color, Button, System, Thread etc.
Interface Should start with uppercase letter and be an adjective e.g.
Runnable, Remote, ActionListener etc.
Method Should start with lowercase letter and be a verb e.g.
actionPerformed(), main(), print(), println() etc.
Variable Should start with lowercase letter e.g. firstName, orderNumber
etc.
Package Should be in lowercase letter e.g. java, lang, sql, util etc.
Constants Should be in uppercase letter. e.g. RED, YELLOW,
MAX_PRIORITY etc.
Basic Data types
Type Size Max Value Min Value Default
boolean 1 True/ False False
byte 8 -128 127 0
short 16 -215 215-1 0
int 32 -232 232-1 0
long 64 -264 264-1 0L
float 32 -232 232-1 0.0f
double 64 -264 264-1 0.0d
Char 16 0 FFFF
Loops and Control Structures
• while
• do … while
• for
• If
• If … else
• switch … case
Java programs
1. Write a java program to check given number is even or odd
2. Write a java program to print series of even numbers between 100
and 150
3. Write a java program to find sum of numbers divisible by 9 between
500 and 1000
4. Write a java program to find factorial of a given number
5. Write a java program to reverse a string
6. Write a java program to find whether the given string is palindrome or
not
7. Write a java program to find the sum of prime numbers below 100
8. Write a java program to find area and perimeter of a circle
9. Write a java program to find area and perimeter of a square
10.Write a java program to sort 3 numbers
Java programs
1. Write a java program to add 10 numbers to an array and sort it in
ascending order
2. Reverse number
3. Add two matrices
4. Display current system date and time
5. swap two numbers
6. Count total number of words in a string
7. Count divisors of an interger number
8. Print multiplication table
9. Save given string to a file
Java programs
• Write a java program to print following patterns
1 2 3 4
*
* *
* * *
* * * *
* * * *
* * *
* *
*
*
* * *
* * * * *
* * * * * * *
*
* *
* * * *
* * * * *
Array and List
Arrays have a fixed size
int arr[ ] = new int[10] ;
List is dynamic in nature
List<int> lst = new ArrayList<int>();
Modifiers
Access Modifiers
• default - Visible to package
• public - Visible everywhere
• private - Visible inside the class
• protected - Visible to package and all subclasses
Non Access modifiers
• static
• final
• abstract
Methods
modifier returnType nameOfMethod (Parameter List) {
// method body
}
Create a class Calculator with methods add, subtract,
multiply and divide. Use it from main method in different
class.
OOP Concepts
• Object-oriented programming (OOP) is a style of
programming that focuses on using objects to design and
build applications.
• Think of an object as a model of the concepts, processes, or
things in the real world that are meaningful to your
application.
Objects in Real World
Real World
Objects
Objects in real world
• Object will have an identity/name
▪ Eg: reynolds, Cello for pen. Nokia,apple for mobile
• Object will have different properties which describes them
best
▪ Eg:Color,size,width
• Object can perform different actions
▪ Eg: writing,erasing etc for pen. Calling, texting for
mobile
Objects
I have an identity:
I'm Volkswagen
I have different properties.
My color property is green
My no:of wheel property is 4
I can perform different actions
I can be drived
I can consume fuel
I can play Music
I have an identity:
I'm Suzuki
I have different properties.
My color property is silver
My no:of wheel property is 4
I can perform different actions
I can be drived
I can consume fuel
I can play Music
How these objects are created?
• All the objects in the real world are created out of a basic
prototype or a basic blue print or a base design
Objects in Software World
Objects in the Software World
• Same like in the real world we can create objects in computer
programming world
– Which will have a name as identity
– Properties to define its behaviour
– Actions what it can perform
How these Objects are created
• We need to create a base design which defines the
properties and functionalities that the object should have.
• In programming terms we call this base design as Class
• Simply by having a class we can create any number of
objects of that type
Definition
• Class : is the base design of objects
• Object : is the instance of a class
• No memory is allocated when a class is created.
• Memory is allocated only when an object is created.
How to create Class in Java
public class Shape
{
private int int_width;
private int int_height;
public int calculateArea()
{
return int_width * int_height;
}
}
How to create Class in Java
public class Shape
{
private int int_width;
private int int_height;
public int calculateArea()
{
return int_width*int_height;
}
}
Is the access specifier
How to create Class in Java
public class Shape
{
private int int_width;
private int int_height;
public int calculateArea()
{
return int_width* int_height;
}
}
Is the keyword for
creating a class
How to create Class in Java
public class Shape
{
private int int_width;
private int int_height;
public int calculateArea()
{
return int_width*int_height;
}
}
Is the name of the class
How to create Class in Java
public class Shape
{
private int int_width;
private int int_height;
public int calculateArea()
{
return int_width* int_height;
}
}
Are two variable that
referred as the
properties. Normally
kept private and access
using getters and
setters. We will discuss
getters and setters later
in this slide
How to create Class in Java
public class Shape
{
private int int_width;
private int int_height;
public int calculateArea()
{
return int_height*int_width;
}
}
Is the only member
function of the class
How to create Objects in Java
Shape rectangle = new Shape();
rectangle.int_width=20;
rectangle.int_height=35;
rArea=rectangle.calculateArea();
This is how we create an
object in java
rectangle
Height:
width:
calculateArea()
{
return height*width;
}
How to create Objects in Java
Shape rectangle = new Shape();
rectangle.width=20;
rectangle.height=35;
rArea=rectangle.calculateArea();
Is the class name
How to create Objects in Java
Shape rectangle = new Shape();
rectangle.int_width=20;
rectangle.int_height=35;
rArea=rectangle.calculateArea();
Is the object name which
we want to create
How to create Objects in Java
Shape rectangle = new Shape();
rectangle.int_width=20;
rectangle.int_height=35;
rArea=rectangle.calculateArea();
“new” is the keyword
used in java to create an
object
How to create Objects in Java
Shape rectangle = new Shape();
rectangle.int_width=20;
rectangle.int_height=35;
rArea=rectangle.calculateArea();
What is this???
It looks like a function
because its having pair of
parentheses (). And also
its having the same name
of our class . But what is it
used for ??
We will discuss it soon .
Just leave it as it is for
now
How to create Objects in Java
Shape rectangle = new Shape();
rectangle.width=20;
rectangle.height=35;
rArea=rectangle.calculateArea();
Setting up the property
values of object
“rectangle”
rectangle
width: 20
Height: 35
calculateArea()
{
return width*height;
}
How to create Objects in Java
Shape rectangle = new Shape();
rectangle.width=20;
rectangle.height=35;
rArea=rectangle.calculateArea();
Calling the method
calculateArea()
rectangle
width: 20
Height: 35
calculateArea()
{
return 20*35;
}
Example
Class : Shape
Height:35
width:20
Object rectangle
calculateArea()
{
Return 20*35
}
Height:10
width:10
Object square
calculateArea()
{
Return 10*10;
}
Member variables
Height
Width
Member function
calculateArea
{
return height*width;
}
What we just did was?
• Created an object
Shape rectangle = new Shape();
Same like we declare variable.
eg: int a;
• And assigned values for it
recangle.int_height=35;
Same like we assign variable value.
eg: a=10;
Rectangle
Width:
Height:
calculateArea()
{
return
width*height;
}
Rectangle
width: 20
Height: 35
calculateArea()
{
return 20*35;
}
THANK YOU

More Related Content

What's hot

The pseudocode
The pseudocodeThe pseudocode
The pseudocodeAsha Sari
 
Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programmingASIT Education
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Hemlathadhevi Annadhurai
 
Java programming - solving problems with software
Java programming - solving problems with softwareJava programming - solving problems with software
Java programming - solving problems with softwareSon Nguyen
 
CS106 Lab 1 - Introduction
CS106 Lab 1 - IntroductionCS106 Lab 1 - Introduction
CS106 Lab 1 - IntroductionNada Kamel
 
Adobe Flash Actionscript language basics chapter-2
Adobe Flash Actionscript language basics chapter-2Adobe Flash Actionscript language basics chapter-2
Adobe Flash Actionscript language basics chapter-2Nafis Ahmed
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Javawiradikusuma
 
How to improve your skills as a programmer
How to improve your skills as a programmerHow to improve your skills as a programmer
How to improve your skills as a programmerYun Yuan
 
Types of program testings and errors
Types of program testings and errorsTypes of program testings and errors
Types of program testings and errorsAmiirah Camall Saib
 
Local variables Instance variables Class/static variables
Local variables Instance variables Class/static variablesLocal variables Instance variables Class/static variables
Local variables Instance variables Class/static variablesSohanur63
 

What's hot (18)

Lecture 23 p1
Lecture 23 p1Lecture 23 p1
Lecture 23 p1
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocode
 
Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
U2A2
U2A2U2A2
U2A2
 
Java programming - solving problems with software
Java programming - solving problems with softwareJava programming - solving problems with software
Java programming - solving problems with software
 
CS106 Lab 1 - Introduction
CS106 Lab 1 - IntroductionCS106 Lab 1 - Introduction
CS106 Lab 1 - Introduction
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Adobe Flash Actionscript language basics chapter-2
Adobe Flash Actionscript language basics chapter-2Adobe Flash Actionscript language basics chapter-2
Adobe Flash Actionscript language basics chapter-2
 
U2A3
U2A3U2A3
U2A3
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
 
Java script
Java scriptJava script
Java script
 
How to improve your skills as a programmer
How to improve your skills as a programmerHow to improve your skills as a programmer
How to improve your skills as a programmer
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Types of program testings and errors
Types of program testings and errorsTypes of program testings and errors
Types of program testings and errors
 
Local variables Instance variables Class/static variables
Local variables Instance variables Class/static variablesLocal variables Instance variables Class/static variables
Local variables Instance variables Class/static variables
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
 

Similar to Core Java Installation and First Program

Similar to Core Java Installation and First Program (20)

Introduction to java and oop
Introduction to java and oopIntroduction to java and oop
Introduction to java and oop
 
Oop java
Oop javaOop java
Oop java
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
 
Core_java_ppt.ppt
Core_java_ppt.pptCore_java_ppt.ppt
Core_java_ppt.ppt
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
 
Android App code starter
Android App code starterAndroid App code starter
Android App code starter
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
 
Java
JavaJava
Java
 
Computer Programming 2
Computer Programming 2 Computer Programming 2
Computer Programming 2
 
constructors.pptx
constructors.pptxconstructors.pptx
constructors.pptx
 
JavaBasicsCore1.ppt
JavaBasicsCore1.pptJavaBasicsCore1.ppt
JavaBasicsCore1.ppt
 
c#(loops,arrays)
c#(loops,arrays)c#(loops,arrays)
c#(loops,arrays)
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 
Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
 
Java
JavaJava
Java
 
Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2
 

More from baabtra.com - No. 1 supplier of quality freshers

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 
Baabtra soft skills
Baabtra soft skillsBaabtra soft skills
Baabtra soft skills
 
Cell phone jammer
Cell phone jammerCell phone jammer
Cell phone jammer
 

Recently uploaded

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 

Recently uploaded (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 

Core Java Installation and First Program

  • 5. First java program First Java Program public class MyClass{ public static void main(String[] args){ System.out.println(“Hello baabtra”); } } Compile the program ->javac MyClass.java Run it ->java MyClass
  • 8. Naming convention Java follows camelcase syntax for naming Type Convention Class Should start with uppercase letter and be a noun e.g. String, Color, Button, System, Thread etc. Interface Should start with uppercase letter and be an adjective e.g. Runnable, Remote, ActionListener etc. Method Should start with lowercase letter and be a verb e.g. actionPerformed(), main(), print(), println() etc. Variable Should start with lowercase letter e.g. firstName, orderNumber etc. Package Should be in lowercase letter e.g. java, lang, sql, util etc. Constants Should be in uppercase letter. e.g. RED, YELLOW, MAX_PRIORITY etc.
  • 9. Basic Data types Type Size Max Value Min Value Default boolean 1 True/ False False byte 8 -128 127 0 short 16 -215 215-1 0 int 32 -232 232-1 0 long 64 -264 264-1 0L float 32 -232 232-1 0.0f double 64 -264 264-1 0.0d Char 16 0 FFFF
  • 10. Loops and Control Structures • while • do … while • for • If • If … else • switch … case
  • 11. Java programs 1. Write a java program to check given number is even or odd 2. Write a java program to print series of even numbers between 100 and 150 3. Write a java program to find sum of numbers divisible by 9 between 500 and 1000 4. Write a java program to find factorial of a given number 5. Write a java program to reverse a string 6. Write a java program to find whether the given string is palindrome or not 7. Write a java program to find the sum of prime numbers below 100 8. Write a java program to find area and perimeter of a circle 9. Write a java program to find area and perimeter of a square 10.Write a java program to sort 3 numbers
  • 12. Java programs 1. Write a java program to add 10 numbers to an array and sort it in ascending order 2. Reverse number 3. Add two matrices 4. Display current system date and time 5. swap two numbers 6. Count total number of words in a string 7. Count divisors of an interger number 8. Print multiplication table 9. Save given string to a file
  • 13. Java programs • Write a java program to print following patterns 1 2 3 4 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  • 14. Array and List Arrays have a fixed size int arr[ ] = new int[10] ; List is dynamic in nature List<int> lst = new ArrayList<int>();
  • 15. Modifiers Access Modifiers • default - Visible to package • public - Visible everywhere • private - Visible inside the class • protected - Visible to package and all subclasses Non Access modifiers • static • final • abstract
  • 16. Methods modifier returnType nameOfMethod (Parameter List) { // method body } Create a class Calculator with methods add, subtract, multiply and divide. Use it from main method in different class.
  • 17. OOP Concepts • Object-oriented programming (OOP) is a style of programming that focuses on using objects to design and build applications. • Think of an object as a model of the concepts, processes, or things in the real world that are meaningful to your application.
  • 20. Objects in real world • Object will have an identity/name ▪ Eg: reynolds, Cello for pen. Nokia,apple for mobile • Object will have different properties which describes them best ▪ Eg:Color,size,width • Object can perform different actions ▪ Eg: writing,erasing etc for pen. Calling, texting for mobile
  • 21. Objects I have an identity: I'm Volkswagen I have different properties. My color property is green My no:of wheel property is 4 I can perform different actions I can be drived I can consume fuel I can play Music I have an identity: I'm Suzuki I have different properties. My color property is silver My no:of wheel property is 4 I can perform different actions I can be drived I can consume fuel I can play Music
  • 22. How these objects are created? • All the objects in the real world are created out of a basic prototype or a basic blue print or a base design
  • 24. Objects in the Software World • Same like in the real world we can create objects in computer programming world – Which will have a name as identity – Properties to define its behaviour – Actions what it can perform
  • 25. How these Objects are created • We need to create a base design which defines the properties and functionalities that the object should have. • In programming terms we call this base design as Class • Simply by having a class we can create any number of objects of that type
  • 26. Definition • Class : is the base design of objects • Object : is the instance of a class • No memory is allocated when a class is created. • Memory is allocated only when an object is created.
  • 27. How to create Class in Java public class Shape { private int int_width; private int int_height; public int calculateArea() { return int_width * int_height; } }
  • 28. How to create Class in Java public class Shape { private int int_width; private int int_height; public int calculateArea() { return int_width*int_height; } } Is the access specifier
  • 29. How to create Class in Java public class Shape { private int int_width; private int int_height; public int calculateArea() { return int_width* int_height; } } Is the keyword for creating a class
  • 30. How to create Class in Java public class Shape { private int int_width; private int int_height; public int calculateArea() { return int_width*int_height; } } Is the name of the class
  • 31. How to create Class in Java public class Shape { private int int_width; private int int_height; public int calculateArea() { return int_width* int_height; } } Are two variable that referred as the properties. Normally kept private and access using getters and setters. We will discuss getters and setters later in this slide
  • 32. How to create Class in Java public class Shape { private int int_width; private int int_height; public int calculateArea() { return int_height*int_width; } } Is the only member function of the class
  • 33. How to create Objects in Java Shape rectangle = new Shape(); rectangle.int_width=20; rectangle.int_height=35; rArea=rectangle.calculateArea(); This is how we create an object in java rectangle Height: width: calculateArea() { return height*width; }
  • 34. How to create Objects in Java Shape rectangle = new Shape(); rectangle.width=20; rectangle.height=35; rArea=rectangle.calculateArea(); Is the class name
  • 35. How to create Objects in Java Shape rectangle = new Shape(); rectangle.int_width=20; rectangle.int_height=35; rArea=rectangle.calculateArea(); Is the object name which we want to create
  • 36. How to create Objects in Java Shape rectangle = new Shape(); rectangle.int_width=20; rectangle.int_height=35; rArea=rectangle.calculateArea(); “new” is the keyword used in java to create an object
  • 37. How to create Objects in Java Shape rectangle = new Shape(); rectangle.int_width=20; rectangle.int_height=35; rArea=rectangle.calculateArea(); What is this??? It looks like a function because its having pair of parentheses (). And also its having the same name of our class . But what is it used for ?? We will discuss it soon . Just leave it as it is for now
  • 38. How to create Objects in Java Shape rectangle = new Shape(); rectangle.width=20; rectangle.height=35; rArea=rectangle.calculateArea(); Setting up the property values of object “rectangle” rectangle width: 20 Height: 35 calculateArea() { return width*height; }
  • 39. How to create Objects in Java Shape rectangle = new Shape(); rectangle.width=20; rectangle.height=35; rArea=rectangle.calculateArea(); Calling the method calculateArea() rectangle width: 20 Height: 35 calculateArea() { return 20*35; }
  • 40. Example Class : Shape Height:35 width:20 Object rectangle calculateArea() { Return 20*35 } Height:10 width:10 Object square calculateArea() { Return 10*10; } Member variables Height Width Member function calculateArea { return height*width; }
  • 41. What we just did was? • Created an object Shape rectangle = new Shape(); Same like we declare variable. eg: int a; • And assigned values for it recangle.int_height=35; Same like we assign variable value. eg: a=10; Rectangle Width: Height: calculateArea() { return width*height; } Rectangle width: 20 Height: 35 calculateArea() { return 20*35; }