PRO192_-_SP_2024_-_Block_5_-_FE_1921.webp
K

PRO192_-_SP_2024_-_Block_5_-_FE_1921.webp

Multiple Choices
(Choose 1 answer)
What will be the output of following code?
class Employee{
private String dob;
public Employee(String dob) {
this.dob = dob;
}
public int getAge(){
String[] t=dob.split("/");
int m=Integer.parseInt(t[1]);
int y=Integer.parseInt(t[2]);
if(m<6)
return (2021-y);
else
}
}
return (2021-y+1);
public class Main{
public static void main(String[] args) {
System.out.println(new Employee("11/06/2000").getAge());
}
}
A. 21
B. 22
C. 19
D. 20

Thông tin

Category
PRO192
Thêm bởi
Kurourushi89
Ngày thêm
Lượt xem
9,620
Lượt bình luận
25
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom