SlideShare a Scribd company logo
JAVA:
Write a java program that:
prompts the user to enter a person's name and age, creates a Person object using a constructor
with those values, and then demonstrates accessing the object's data and methods. It should also
demonstrate accessing a static variable and method from the Person class.
Enter the person's name: Alice
Enter the person's age: 25
Name: Alice
Age: 25
New age: 26
Total number of people: 1
1. Creating objects using constructors 2. Accessing an objects data and methods 3. Distinguishing
between instance and static variables and methods
import java.util.Scanner;
public class Exercise2 {
public static void main(String[] args) {
}
}

More Related Content

More from accuratemobilepune

Suppose that XY and Z are jointly distributed random varia.pdf
Suppose that XY and Z are jointly distributed random varia.pdfSuppose that XY and Z are jointly distributed random varia.pdf
Suppose that XY and Z are jointly distributed random varia.pdf
accuratemobilepune
 
slove mcq sorular Paydalarn bilgi ve iletiim ihtiyalarnn b.pdf
slove mcq sorular  Paydalarn bilgi ve iletiim ihtiyalarnn b.pdfslove mcq sorular  Paydalarn bilgi ve iletiim ihtiyalarnn b.pdf
slove mcq sorular Paydalarn bilgi ve iletiim ihtiyalarnn b.pdf
accuratemobilepune
 
Select one 1 priority nursing diagnosis include related .pdf
Select one 1 priority nursing diagnosis include related .pdfSelect one 1 priority nursing diagnosis include related .pdf
Select one 1 priority nursing diagnosis include related .pdf
accuratemobilepune
 
Research about sharing information online suggests that trus.pdf
Research about sharing information online suggests that trus.pdfResearch about sharing information online suggests that trus.pdf
Research about sharing information online suggests that trus.pdf
accuratemobilepune
 
4 Below is a banding diagram of human chromosomes a Does .pdf
4 Below is a banding diagram of human chromosomes a Does .pdf4 Below is a banding diagram of human chromosomes a Does .pdf
4 Below is a banding diagram of human chromosomes a Does .pdf
accuratemobilepune
 
Question 4 MCS51 MCUs program storage can be internal or e.pdf
Question 4 MCS51 MCUs program storage can be internal or e.pdfQuestion 4 MCS51 MCUs program storage can be internal or e.pdf
Question 4 MCS51 MCUs program storage can be internal or e.pdf
accuratemobilepune
 
Problem 2 Suppose fXx1300x3otherwiseandfYycy00.pdf
Problem 2 Suppose fXx1300x3otherwiseandfYycy00.pdfProblem 2 Suppose fXx1300x3otherwiseandfYycy00.pdf
Problem 2 Suppose fXx1300x3otherwiseandfYycy00.pdf
accuratemobilepune
 
Part 2 Watch the video 2013 Global Health and Disasters Co.pdf
Part 2 Watch the video 2013 Global Health and Disasters Co.pdfPart 2 Watch the video 2013 Global Health and Disasters Co.pdf
Part 2 Watch the video 2013 Global Health and Disasters Co.pdf
accuratemobilepune
 
Let F be a continuous distribution function ie FR01 i.pdf
Let F be a continuous distribution function ie FR01 i.pdfLet F be a continuous distribution function ie FR01 i.pdf
Let F be a continuous distribution function ie FR01 i.pdf
accuratemobilepune
 
Ltfen aklamalar salayn 17 Gney Amerikada bir lke by.pdf
Ltfen aklamalar salayn  17 Gney Amerikada bir lke by.pdfLtfen aklamalar salayn  17 Gney Amerikada bir lke by.pdf
Ltfen aklamalar salayn 17 Gney Amerikada bir lke by.pdf
accuratemobilepune
 
Match the description with the appropriate structure 1 Mos.pdf
Match the description with the appropriate structure 1 Mos.pdfMatch the description with the appropriate structure 1 Mos.pdf
Match the description with the appropriate structure 1 Mos.pdf
accuratemobilepune
 
Jackie the director of strategic planning at Healthy Hospit.pdf
Jackie the director of strategic planning at Healthy Hospit.pdfJackie the director of strategic planning at Healthy Hospit.pdf
Jackie the director of strategic planning at Healthy Hospit.pdf
accuratemobilepune
 
indespondent of the ethers a What is the probabily that th.pdf
indespondent of the ethers a What is the probabily that th.pdfindespondent of the ethers a What is the probabily that th.pdf
indespondent of the ethers a What is the probabily that th.pdf
accuratemobilepune
 
How many different 10 letter words real or imaginary can .pdf
How many different 10 letter words real or imaginary can .pdfHow many different 10 letter words real or imaginary can .pdf
How many different 10 letter words real or imaginary can .pdf
accuratemobilepune
 
Helga a cybersecurity analyst has just been hired by a maj.pdf
Helga a cybersecurity analyst has just been hired by a maj.pdfHelga a cybersecurity analyst has just been hired by a maj.pdf
Helga a cybersecurity analyst has just been hired by a maj.pdf
accuratemobilepune
 
1 Risk and uncertainty are inherent parts of all project wo.pdf
1 Risk and uncertainty are inherent parts of all project wo.pdf1 Risk and uncertainty are inherent parts of all project wo.pdf
1 Risk and uncertainty are inherent parts of all project wo.pdf
accuratemobilepune
 
Generation Y has been defined as those individuals who were .pdf
Generation Y has been defined as those individuals who were .pdfGeneration Y has been defined as those individuals who were .pdf
Generation Y has been defined as those individuals who were .pdf
accuratemobilepune
 
answer all please 1 Introduction to the Three 3 Domain sy.pdf
answer all please 1 Introduction to the Three 3 Domain sy.pdfanswer all please 1 Introduction to the Three 3 Domain sy.pdf
answer all please 1 Introduction to the Three 3 Domain sy.pdf
accuratemobilepune
 
Find Pz13 In your answer include the following a A pi.pdf
Find Pz13 In your answer include the following a A pi.pdfFind Pz13 In your answer include the following a A pi.pdf
Find Pz13 In your answer include the following a A pi.pdf
accuratemobilepune
 
A continuacin se presenta una nota informativa para Matsui .pdf
A continuacin se presenta una nota informativa para Matsui .pdfA continuacin se presenta una nota informativa para Matsui .pdf
A continuacin se presenta una nota informativa para Matsui .pdf
accuratemobilepune
 

More from accuratemobilepune (20)

Suppose that XY and Z are jointly distributed random varia.pdf
Suppose that XY and Z are jointly distributed random varia.pdfSuppose that XY and Z are jointly distributed random varia.pdf
Suppose that XY and Z are jointly distributed random varia.pdf
 
slove mcq sorular Paydalarn bilgi ve iletiim ihtiyalarnn b.pdf
slove mcq sorular  Paydalarn bilgi ve iletiim ihtiyalarnn b.pdfslove mcq sorular  Paydalarn bilgi ve iletiim ihtiyalarnn b.pdf
slove mcq sorular Paydalarn bilgi ve iletiim ihtiyalarnn b.pdf
 
Select one 1 priority nursing diagnosis include related .pdf
Select one 1 priority nursing diagnosis include related .pdfSelect one 1 priority nursing diagnosis include related .pdf
Select one 1 priority nursing diagnosis include related .pdf
 
Research about sharing information online suggests that trus.pdf
Research about sharing information online suggests that trus.pdfResearch about sharing information online suggests that trus.pdf
Research about sharing information online suggests that trus.pdf
 
4 Below is a banding diagram of human chromosomes a Does .pdf
4 Below is a banding diagram of human chromosomes a Does .pdf4 Below is a banding diagram of human chromosomes a Does .pdf
4 Below is a banding diagram of human chromosomes a Does .pdf
 
Question 4 MCS51 MCUs program storage can be internal or e.pdf
Question 4 MCS51 MCUs program storage can be internal or e.pdfQuestion 4 MCS51 MCUs program storage can be internal or e.pdf
Question 4 MCS51 MCUs program storage can be internal or e.pdf
 
Problem 2 Suppose fXx1300x3otherwiseandfYycy00.pdf
Problem 2 Suppose fXx1300x3otherwiseandfYycy00.pdfProblem 2 Suppose fXx1300x3otherwiseandfYycy00.pdf
Problem 2 Suppose fXx1300x3otherwiseandfYycy00.pdf
 
Part 2 Watch the video 2013 Global Health and Disasters Co.pdf
Part 2 Watch the video 2013 Global Health and Disasters Co.pdfPart 2 Watch the video 2013 Global Health and Disasters Co.pdf
Part 2 Watch the video 2013 Global Health and Disasters Co.pdf
 
Let F be a continuous distribution function ie FR01 i.pdf
Let F be a continuous distribution function ie FR01 i.pdfLet F be a continuous distribution function ie FR01 i.pdf
Let F be a continuous distribution function ie FR01 i.pdf
 
Ltfen aklamalar salayn 17 Gney Amerikada bir lke by.pdf
Ltfen aklamalar salayn  17 Gney Amerikada bir lke by.pdfLtfen aklamalar salayn  17 Gney Amerikada bir lke by.pdf
Ltfen aklamalar salayn 17 Gney Amerikada bir lke by.pdf
 
Match the description with the appropriate structure 1 Mos.pdf
Match the description with the appropriate structure 1 Mos.pdfMatch the description with the appropriate structure 1 Mos.pdf
Match the description with the appropriate structure 1 Mos.pdf
 
Jackie the director of strategic planning at Healthy Hospit.pdf
Jackie the director of strategic planning at Healthy Hospit.pdfJackie the director of strategic planning at Healthy Hospit.pdf
Jackie the director of strategic planning at Healthy Hospit.pdf
 
indespondent of the ethers a What is the probabily that th.pdf
indespondent of the ethers a What is the probabily that th.pdfindespondent of the ethers a What is the probabily that th.pdf
indespondent of the ethers a What is the probabily that th.pdf
 
How many different 10 letter words real or imaginary can .pdf
How many different 10 letter words real or imaginary can .pdfHow many different 10 letter words real or imaginary can .pdf
How many different 10 letter words real or imaginary can .pdf
 
Helga a cybersecurity analyst has just been hired by a maj.pdf
Helga a cybersecurity analyst has just been hired by a maj.pdfHelga a cybersecurity analyst has just been hired by a maj.pdf
Helga a cybersecurity analyst has just been hired by a maj.pdf
 
1 Risk and uncertainty are inherent parts of all project wo.pdf
1 Risk and uncertainty are inherent parts of all project wo.pdf1 Risk and uncertainty are inherent parts of all project wo.pdf
1 Risk and uncertainty are inherent parts of all project wo.pdf
 
Generation Y has been defined as those individuals who were .pdf
Generation Y has been defined as those individuals who were .pdfGeneration Y has been defined as those individuals who were .pdf
Generation Y has been defined as those individuals who were .pdf
 
answer all please 1 Introduction to the Three 3 Domain sy.pdf
answer all please 1 Introduction to the Three 3 Domain sy.pdfanswer all please 1 Introduction to the Three 3 Domain sy.pdf
answer all please 1 Introduction to the Three 3 Domain sy.pdf
 
Find Pz13 In your answer include the following a A pi.pdf
Find Pz13 In your answer include the following a A pi.pdfFind Pz13 In your answer include the following a A pi.pdf
Find Pz13 In your answer include the following a A pi.pdf
 
A continuacin se presenta una nota informativa para Matsui .pdf
A continuacin se presenta una nota informativa para Matsui .pdfA continuacin se presenta una nota informativa para Matsui .pdf
A continuacin se presenta una nota informativa para Matsui .pdf
 

Recently uploaded

How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Vivekanand Anglo Vedic Academy
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 

Recently uploaded (20)

How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 

JAVA Write a java program that prompts the user to enter a.pdf

  • 1. JAVA: Write a java program that: prompts the user to enter a person's name and age, creates a Person object using a constructor with those values, and then demonstrates accessing the object's data and methods. It should also demonstrate accessing a static variable and method from the Person class. Enter the person's name: Alice Enter the person's age: 25 Name: Alice Age: 25 New age: 26 Total number of people: 1 1. Creating objects using constructors 2. Accessing an objects data and methods 3. Distinguishing between instance and static variables and methods import java.util.Scanner; public class Exercise2 { public static void main(String[] args) { } }