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

More Related Content

What's hot (16)

PDF
The pseudocode
Asha Sari
 
PPT
Introduction to java programming
ASIT Education
 
PPT
Introducing object oriented programming (oop)
Hemlathadhevi Annadhurai
 
PPTX
Java programming - solving problems with software
Son Nguyen
 
PPSX
CS106 Lab 1 - Introduction
Nada Kamel
 
PPTX
Programming Fundamentals
Trivuz ত্রিভুজ
 
PPTX
Adobe Flash Actionscript language basics chapter-2
Nafis Ahmed
 
KEY
Practical OOP In Java
wiradikusuma
 
PPTX
Java script
Athi Sethu
 
PPT
How to improve your skills as a programmer
Yun Yuan
 
PPTX
Object oriented programming
Saiful Islam Sany
 
PPTX
Types of program testings and errors
Amiirah Camall Saib
 
PPTX
Local variables Instance variables Class/static variables
Sohanur63
 
PPT
Final keyword in java
Lovely Professional University
 
The pseudocode
Asha Sari
 
Introduction to java programming
ASIT Education
 
Introducing object oriented programming (oop)
Hemlathadhevi Annadhurai
 
Java programming - solving problems with software
Son Nguyen
 
CS106 Lab 1 - Introduction
Nada Kamel
 
Programming Fundamentals
Trivuz ত্রিভুজ
 
Adobe Flash Actionscript language basics chapter-2
Nafis Ahmed
 
Practical OOP In Java
wiradikusuma
 
Java script
Athi Sethu
 
How to improve your skills as a programmer
Yun Yuan
 
Object oriented programming
Saiful Islam Sany
 
Types of program testings and errors
Amiirah Camall Saib
 
Local variables Instance variables Class/static variables
Sohanur63
 
Final keyword in java
Lovely Professional University
 

Similar to Core java - baabtra (20)

PDF
Introduction to java and oop
baabtra.com - No. 1 supplier of quality freshers
 
PPT
Intro Java Rev010
Rich Helton
 
PPTX
Curso de Programación Java Básico
Universidad de Occidente
 
PPT
Java
Manav Prasad
 
PPT
java01.pptbvuyvyuvvvvvvvvvvvvvvvvvvvvyft
nagendrareddy104104
 
PPT
Java Simple Introduction in single course
binzbinz3
 
PDF
Javanotes
John Cutajar
 
PPT
java01.ppt
Godwin585235
 
PPT
Lecture 2 classes i
the_wumberlog
 
PPT
java-corporate-training-institute-in-mumbai
Unmesh Baile
 
PPT
java-corporate-training-institute-in-mumbai
vibrantuser
 
PPTX
Java programmingjsjdjdjdjdjdjdjdjdiidiei
rajputtejaswa12
 
PPTX
Nitish Chaulagai Java1.pptx
NitishChaulagai
 
PDF
JAVA Object Oriented Programming (OOP)
Prof. Erwin Globio
 
PPTX
Android webinar class_java_review
Edureka!
 
DOCX
javaopps concepts
Nikhil Agrawal
 
PPT
Ap Power Point Chpt4
dplunkett
 
PPTX
Core java
Ravi varma
 
PPTX
Core java &collections
Ravi varma
 
PPTX
Core java1
Ravi varma
 
Intro Java Rev010
Rich Helton
 
Curso de Programación Java Básico
Universidad de Occidente
 
java01.pptbvuyvyuvvvvvvvvvvvvvvvvvvvvyft
nagendrareddy104104
 
Java Simple Introduction in single course
binzbinz3
 
Javanotes
John Cutajar
 
java01.ppt
Godwin585235
 
Lecture 2 classes i
the_wumberlog
 
java-corporate-training-institute-in-mumbai
Unmesh Baile
 
java-corporate-training-institute-in-mumbai
vibrantuser
 
Java programmingjsjdjdjdjdjdjdjdjdiidiei
rajputtejaswa12
 
Nitish Chaulagai Java1.pptx
NitishChaulagai
 
JAVA Object Oriented Programming (OOP)
Prof. Erwin Globio
 
Android webinar class_java_review
Edureka!
 
javaopps concepts
Nikhil Agrawal
 
Ap Power Point Chpt4
dplunkett
 
Core java
Ravi varma
 
Core java &collections
Ravi varma
 
Core java1
Ravi varma
 
Ad

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

PPTX
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
PDF
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 3 stored procedures
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
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
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Ad

Recently uploaded (20)

PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
July Patch Tuesday
Ivanti
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
July Patch Tuesday
Ivanti
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 

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