Object: Instance of class are called object.
Syntax of Object:
public class Tom {
public Tom(String name) {
// This constructor has one parameter, name.
System.out.println("Passed Name is :" + name );
}
public static void main(String []args) {
// Following statement would create an object myTom
Puppy myTom = new Tom( "nazrul" );
}
}
Output:
Passed Name is : nazrul
Syntax of Object:
public class Tom {
public Tom(String name) {
// This constructor has one parameter, name.
System.out.println("Passed Name is :" + name );
}
public static void main(String []args) {
// Following statement would create an object myTom
Puppy myTom = new Tom( "nazrul" );
}
}
Output:
Passed Name is : nazrul
0 comments:
Post a Comment