Question: final class Human { String gender; public void setGender ( String gender ) { this.gender = gender; } public String getGender ( ) { return

final class Human {
String gender;
public void setGender(String gender){
this.gender=gender;
}
public String getGender(){
return this.gender;
}
}
class Man extends Human {
public void setGender(String gender){
this.gender=gender;
}
}
public class Demo {
public static void main(String[] args){
Man obj=new Man();
obj.setGender("Male");
System.out.println("Gender is "+obj.getGender());
}
}
Select the correct output of this code.
a. Gender is Male
b. ClassNotFoundException
c. A compile-time error
d. Gender is female

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!