PRO192_FE_SP23_311.webp
Soram

PRO192_FE_SP23_311.webp

  • Media owner Soram
  • Ngày thêm
Bài viết gốc: Chủ đề 'PRO192 FE SP23'
(Choose 1 answer)
Given the following. What is the result?
public class Example {
public static void main(String[] args) {
Person p1 = new Person("Hung", 20);
Person p2 = new Person("Ha", 22);
Person p3 = (new Example()).change(p2, "Nam");
System.out.println(p3.getCode()+""+ p3. p3.name + + p3.age);
}
public Person change(Person p, String name) {
Person p1 = p;
p1.name=name;
return p1;
}
}
class Person {
private int code;
String name:
int age;
public Person(String name, int age) {
this.code++:
this.name = name;
this.age = age;
}
public int getCode() {return code;}
}
A. ClassCastException is thrown at runtime
B. Compilation fails
C 1 Nam 22
Eut

Thông tin

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

Share this media

Back
Bên trên Bottom