|
a constructor is a method in the class which gets executed when its object is created. Usually, we put the initialization code in the constructor. Writing a constructor in the class is damn simple, have a look at the following sample:
public class Test
{
public Test()
{
//Initilize code in the constructor. } }
Method:
-
In methods we can define variables.These variables scope is within methods only.
-
If you declare a public variable , it will be accessed in all mehtods.
-
Methods may/maynot contains return type.
-
Methods could be inhereted in derived class(Note That mehtod should be Public)
|