SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (16)

The pseudocode
The pseudocodeThe pseudocode
The pseudocode
Asha Sari
 
Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
ASIT Education
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)
Hemlathadhevi Annadhurai
 
U2A2
U2A2U2A2
U2A2
pfefferteacher
 
Java programming - solving problems with software
Java programming - solving problems with softwareJava programming - solving problems with software
Java programming - solving problems with software
Son Nguyen
 
CS106 Lab 1 - Introduction
CS106 Lab 1 - IntroductionCS106 Lab 1 - Introduction
CS106 Lab 1 - Introduction
Nada Kamel
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
Trivuz ত্রিভুজ
 
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
Nafis Ahmed
 
U2A3
U2A3U2A3
U2A3
pfefferteacher
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
wiradikusuma
 
Java script
Java scriptJava script
Java script
Athi Sethu
 
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
Yun Yuan
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Saiful Islam Sany
 
Types of program testings and errors
Types of program testings and errorsTypes of program testings and errors
Types of program testings and errors
Amiirah 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 variables
Sohanur63
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
Lovely Professional University
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocode
Asha Sari
 
Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
ASIT 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 software
Son Nguyen
 
CS106 Lab 1 - Introduction
CS106 Lab 1 - IntroductionCS106 Lab 1 - Introduction
CS106 Lab 1 - Introduction
Nada 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-2
Nafis Ahmed
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
wiradikusuma
 
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
Yun Yuan
 
Types of program testings and errors
Types of program testings and errorsTypes of program testings and errors
Types of program testings and errors
Amiirah 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 variables
Sohanur63
 

Similar to Core java - baabtra (20)

Introduction to java and oop
Introduction to java and oopIntroduction to java and oop
Introduction to java and oop
baabtra.com - No. 1 supplier of quality freshers
 
Oop java
Oop javaOop java
Oop java
Minal Maniar
 
Java-U1-C_1.2.pptx its all about the java
Java-U1-C_1.2.pptx its all about the javaJava-U1-C_1.2.pptx its all about the java
Java-U1-C_1.2.pptx its all about the java
delta210210210
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
VijalJain3
 
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
Ahmad sohail Kakar
 
Core_java_ppt.ppt
Core_java_ppt.pptCore_java_ppt.ppt
Core_java_ppt.ppt
SHIBDASDUTTA
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
LovelitJose
 
2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud
vyshukodumuri
 
Java Classes fact general wireless-19*5.pptx
Java Classes fact general wireless-19*5.pptxJava Classes fact general wireless-19*5.pptx
Java Classes fact general wireless-19*5.pptx
IbrahimMerzayiee
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
rishi ram khanal
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
SARJERAO Sarju
 
Android App code starter
Android App code starterAndroid App code starter
Android App code starter
FatimaYousif11
 
Jaga codinghshshshshehwuwiwijsjssnndnsjd
Jaga codinghshshshshehwuwiwijsjssnndnsjdJaga codinghshshshshehwuwiwijsjssnndnsjd
Jaga codinghshshshshehwuwiwijsjssnndnsjd
rajputtejaswa12
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
mcollison
 
Java
JavaJava
Java
Zeeshan Khan
 
Computer Programming 2
Computer Programming 2 Computer Programming 2
Computer Programming 2
VasanthiMuniasamy2
 
OOPS JavaScript Interview Questions PDF By ScholarHat
OOPS JavaScript Interview Questions PDF By ScholarHatOOPS JavaScript Interview Questions PDF By ScholarHat
OOPS JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
constructors.pptx
constructors.pptxconstructors.pptx
constructors.pptx
Epsiba1
 
JavaBasicsCore1.ppt
JavaBasicsCore1.pptJavaBasicsCore1.ppt
JavaBasicsCore1.ppt
buvanabala
 
object oriented programming unit one ppt
object oriented programming unit one pptobject oriented programming unit one ppt
object oriented programming unit one ppt
isiagnel2
 
Java-U1-C_1.2.pptx its all about the java
Java-U1-C_1.2.pptx its all about the javaJava-U1-C_1.2.pptx its all about the java
Java-U1-C_1.2.pptx its all about the java
delta210210210
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
VijalJain3
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
LovelitJose
 
2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud
vyshukodumuri
 
Java Classes fact general wireless-19*5.pptx
Java Classes fact general wireless-19*5.pptxJava Classes fact general wireless-19*5.pptx
Java Classes fact general wireless-19*5.pptx
IbrahimMerzayiee
 
Android App code starter
Android App code starterAndroid App code starter
Android App code starter
FatimaYousif11
 
Jaga codinghshshshshehwuwiwijsjssnndnsjd
Jaga codinghshshshshehwuwiwijsjssnndnsjdJaga codinghshshshshehwuwiwijsjssnndnsjd
Jaga codinghshshshshehwuwiwijsjssnndnsjd
rajputtejaswa12
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
mcollison
 
OOPS JavaScript Interview Questions PDF By ScholarHat
OOPS JavaScript Interview Questions PDF By ScholarHatOOPS JavaScript Interview Questions PDF By ScholarHat
OOPS JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
constructors.pptx
constructors.pptxconstructors.pptx
constructors.pptx
Epsiba1
 
JavaBasicsCore1.ppt
JavaBasicsCore1.pptJavaBasicsCore1.ppt
JavaBasicsCore1.ppt
buvanabala
 
object oriented programming unit one ppt
object oriented programming unit one pptobject oriented programming unit one ppt
object oriented programming unit one ppt
isiagnel2
 
Ad

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
baabtra.com - No. 1 supplier of quality freshers
 
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 - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
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
baabtra.com - No. 1 supplier of quality freshers
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
baabtra.com - No. 1 supplier of quality freshers
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
baabtra.com - No. 1 supplier of quality freshers
 
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
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
baabtra.com - No. 1 supplier of quality freshers
 
Blue brain
Blue brainBlue brain
Blue brain
baabtra.com - No. 1 supplier of quality freshers
 
5g
5g5g
5g
baabtra.com - No. 1 supplier of quality freshers
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
baabtra.com - No. 1 supplier of quality freshers
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra soft skills
Baabtra soft skillsBaabtra soft skills
Baabtra soft skills
baabtra.com - No. 1 supplier of quality freshers
 
Cell phone jammer
Cell phone jammerCell phone jammer
Cell phone jammer
baabtra.com - No. 1 supplier of quality freshers
 
Ad

Recently uploaded (20)

Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 

Core java - baabtra

  • 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; }