Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following code ( which is the same as in Q 1 ) : public class Person { private int age; public Person (

Given the following code (which is the same as in Q1):
public class Person {
private int age;
public Person(){
age =1;
}
public int getAge(){
return age;
}
public void getOlderByYears(int years){
age = age + years;
years = years +1;
// POINT A
}
}
public class Main {
public static void main(String[] args){
Person jean = new Person();
int ageAmount =3;
//POINT B
jean.getOlderByYears(ageAmount);
//POINT C
}
}
Part 1
When we run the Java program above, what is the value of years at Point A?
(a)
expression does not compile at Point A
(b)
3
(c)
4
(d)
0
(e)
2
(f)
1
0%
Part 2
When we run the Java program above, what is the value of years at Point B?
(a)
3
(b)
1
(c)
2
(d)
4
(e)
expression does not compile at Point B
(f)
0
0%
Part 3
When we run the Java program above, what is the value of years at Point C?
(a)
expression does not compile at Point C
(b)
0
(c)
3
(d)
1
(e)
4
(f)
2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions