题海让大学四年没有难题
白天模式登陆

题目详情

单选题 请阅读程序,写出程序运行结果. //写出程序运行结果 class Eye {// 猫的眼睛类 private String color; public Eye(String color) { this.color = color; } } class Cat {// 猫类 private String name; private Eye eye; public Cat(String name, Eye eye) { this.name = name; this.eye = eye; } public boolean equals(Object obj) { Cat cat = (Cat) obj; if (this.name.equals(cat.name) && this.eye == cat.eye) return true; return false; } } public class CatDemo { public static void main(String[] args) { Eye e1=new Eye("蓝色"); Eye e2=new Eye("蓝色"); Cat tom=new Cat("Tome",e1); Cat jack=new Cat("Jack",e2); System.out.println(tom==jack); System.out.println(tom.equals(jack)); } }

默认课程课程封面

学科:默认课程

时间:2025-11-25 05:29:21

Copyright © 2022 津ICP备2021001502号