Skip to content

Commit 2622079

Browse files
committed
Added Comments
1 parent 40344f9 commit 2622079

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

H_Objects.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ class Vehicle
99
{
1010
private String color;
1111

12-
/**
12+
/**********************************************************************
1313
Constructor
1414
A constructor can be used to provide initial values for object attributes.
1515
- A constructor name must be same as its class name.
1616
- A constructor must have no explicit return type.
17-
*/
17+
************************************************************************/
1818
Vehicle()
1919
{
2020
color = "Red";
@@ -23,10 +23,10 @@ class Vehicle
2323
{
2424
this.setColor(c);
2525
}
26-
/**
26+
/***********************************************************************************
2727
Java automatically provides a default constructor, so all classes have a constructor,
2828
whether one is specifically defined or not.
29-
*/
29+
*************************************************************************************/
3030

3131
// Getter
3232
public String getColor()
@@ -39,33 +39,33 @@ public void setColor(String c)
3939
{
4040
this.color = c;
4141
}
42-
/**
42+
/*********************************************************************
4343
Getters and setters are fundamental building blocks for encapsulation,
44-
*/
44+
**********************************************************************/
4545
}
4646
class H_Objects
4747
{
4848
public static void main(String[ ] args)
4949
{
5050
Animal dog = new Animal();
5151
dog.bark();
52-
/**
52+
/***********************************************************************
5353
Now, dog is an object of type Animal. Thus we can call its bark() method,
5454
using the name of the object and a dot. The dot notation is used to access
5555
the object's attributes and methods.
56-
*/
56+
************************************************************************/
5757
Vehicle v1 = new Vehicle();
5858
v1.setColor("Green");
5959
System.out.println(v1.getColor());
6060
Vehicle v2 = new Vehicle("Blue");
6161
System.out.println(v2.getColor());
6262
}
6363
}
64-
/**
64+
/**********************************************************************************
6565
default: A variable or method declared with no access control modifier is available
6666
to any other class in the same package.
6767
public: Accessible from any other class.
6868
protected: Provides the same access as the default access modifier, with the addition
6969
that subclasses can access protected methods and variables of the superclass
7070
private: Accessible only within the declared class itself.
71-
*/
71+
***********************************************************************************/

0 commit comments

Comments
 (0)