Hws, ch342 1. R3.7 Should the Counter class have a setValue method? R3.11 About
ID: 3589437 • Letter: H
Question
Hws, ch342 1. R3.7 Should the Counter class have a setValue method? R3.11 About this The next three questions are about the class MusicCD as given in HW4, Ch3Part1 public class MusicCD t private int id; private String artist; public static final string STUDIO "Sony" public MusicCD)) public MusicCD (int i, string a) { this.id i; this.artist a; public void setId (int n) ( id-n: public int search (char o) ( int index0 // more code return index; 2. How many methods are there? Use words to describe each method (its visibility, its return type, its parameters) 3. How many constructors are defined? Describe each 4. Is there any getters or setters defined? Describe eachExplanation / Answer
2)
a) There are two methods setId and search.
b ) Both are public means it can be accessed outside the class
c ) setId return type is void means it wont return anything where as
d ) search method return type is integer means it returns an integer
3) There are two constructors defined
a) One is default constructor that takes no argument i.e MusicCD() { }
b) Second is parameterized constructor that takes two argument of type int and string i.e MusicCD(int i , String x) { }
4) There are no getters defined but there is one setter that sets the Id
a) setId is the only setter defined and its return type is void
Thanks, let me know if there is any doubts
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.