- 3
Drag and drop from the options below to create a valid Java code with encapsulation. public class Person { int age;
Drag and drop from the options below to create a valid Java code with encapsulation. public class Person { int age; void setAge( age) { if (age > 0) { this.age = age; } } } public static int private String final
13 Réponses
+ 5
public class Person {
private int age;
public void setAge(int age) {
if(age > 0) {
this.age = age;
Rember that you habe to use "private" to achieve encapsulation in Java (that's why private is the first word).
setAge is a public void (you don't need to hide it, as it was done for int age for the encapsulation ).
Age is represented as an integer number (in java integer = int). The tird word is int.
I hope it helped!
+ 2
interger, new, ArrayList
+ 2
to declare an ArrayList to hold 9 Integers:
interger
new
ArrayList
0
Here is the answer
interger
new
ArrayList
0
1 iterator
2 integer
3 iterator
4 hasnext
5 next
0
That Epic!
0
mali yung iba
0
public class room
public int/*
0
Drag and drop from the options below to create a valid Java code with encapsulation.
public class Person {
private int age;
public void setAge(int age) {
if (age > 0) {
this.age = age;
}
}
}
Enjoy
0
linkedlist
string
hey
0
0
interger
new
ArrayList
0
Drag and drop from the options below to create a valid Java code with encapsulation.
public class Person {
private int age;
public void setAge(int age) {
if (age > 0) {
this.age = age;
}
}
}
0
public class Person {
private int age;
public void setAge(int age) {
if (age > 0) {
this.age = age;
}
}
}