- Add Comments to the Code below and label the following using comments:
- Class name
- All instance variables/fields and their data-types
- The Constructor and the Constructor Parameters
- Where a Student object gets created.
- Where the instance variables value gets set and what its values are.
- All the instance methods for the class Student
class Student{
private String name;
private int rollNo;
Student(String s, int r)
{
name = s;
rollNo = r;
}
void methodForDisplay()
{
System.out.println(name+"'s Roll No: "+rollNo);
}
public static void main(String[] args) {
Student obj1=new Student("Rambo",21);
obj1.methodForDisplay();
}
}- Read the W3Schools page on class methods: W3Schools Java Class Methods
- In your own words, write a few sentences below explaining the difference between static and public methods in relation to a class.
-
View the image below, and from the image, construct a Java file Dog that mirrors the diagrammed class and the 3 dog objects.

-
Your class should be named Dog
-
You should have private instance variables/fields for all the data members.
-
You should have a constructor that sets the initial state of the data members via passed parameters.
- Think about what data-types the fields and parameters will need!!!
-
You should have 4 instance methods for eat, run, sleep, and name
-
You should have a main method that creates the 3 Dog objects in the diagram.
-
Make at least 2 of your methods functional (i.e. perform some action)!!!
- For Example: method eat might take a class parameter named Food (i.e. another class) that has a field weight, and your eat method might reduce the weight in Food.
- Create a feature branch Feature1
- Commit your code and push it back to your account.
- Create a Pull request as you have been doing for all assignments.
- Paste the Pull request URL back into the Canvass assignment page for credit.