Write a Java class Author with following features:
• Instance variables :
o firstName for the author’s first name of type String.
o lastName for the author’s last name of type String.
• Constructor:
o public Author (String firstName, String lastName): A constructor with parameters, it
creates the Author object by setting the two fields to the passed values.
• Instance methods:
o public void setFirstName (String firstName): Used to set the first name of author.
o public void setLastName (String lastName): Used to set the last name of author.
o public double getFirstName(): This method returns the first name of the author.
o public double getLastName(): This method returns the last name of the author.
o public String toString(): This method printed out author’s name to the screen
السؤال
Alaa Emam
Write a Java class Author with following features:
• Instance variables :
o firstName for the author’s first name of type String.
o lastName for the author’s last name of type String.
• Constructor:
o public Author (String firstName, String lastName): A constructor with parameters, it
creates the Author object by setting the two fields to the passed values.
• Instance methods:
o public void setFirstName (String firstName): Used to set the first name of author.
o public void setLastName (String lastName): Used to set the last name of author.
o public double getFirstName(): This method returns the first name of the author.
o public double getLastName(): This method returns the last name of the author.
o public String toString(): This method printed out author’s name to the screen
3 أجوبة على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.