Give an example of a valid fully qualified name? Create a student class that has
ID: 3789851 • Letter: G
Question
Give an example of a valid fully qualified name? Create a student class that has three private fields (name, gpa, and id number) and one method to print out the values of these fields by using a printf statement? What type of constructor the compiler will create if there is no constructor coded in the class? The methods that allow a client of a class to assign values to a private instance variable are known as:_? A well-designed method performs how many tasks? When should you declare variables as fields rather than local variables? Write a get/set method for accessing the courseName declared below? private String courseName;//course name for this GradeBook Place calls to the set/get methods for processing courseName found in the above question? Class level identifiers have what scope?Explanation / Answer
39: Give an example of fully qualified name.
Sol: Represent using package_name.class_name
Suppose a class Shape is present in package 'symbol' is called
Fully Qualified name: symbol.Shape
40.Create student class
class Student{
private String name;
private double gpa;
private int id;
void printData(){
System.out.printf("%s %f %d", name, gpa, id);
}
}
41. What type of constructor is created using if there is not constructor is coded in class?
Solution : default or zero argument constructor
42. Method that allows client to assign values is called setter methods.
43. Well defined method performs single well defined task.
44. Declare variables as fields when variable is to bound for a object itself.
45. Given variable
private String courseName;
String getCourseName(){
return this.courseName;
}
String setCourseName(String course){
this.courseName = course;
}
void setCourseName(String course,name){}
void getCourseName(){}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.