Week8 - AC1 - Attributes Methods and Constructors Characters and String
Week8 - AC1 - Attributes Methods and Constructors Characters and String
INITIALIZE ATTRIBUTES
USING CONSTRUCTORS.
Example:
public class SampleClass extends SomeSuperClass
{
private String attributeName = “sample”;
private int age = 20;
private char section = ‘A’;
}
System.out.println(“Hello world”);
Observe that the method consists of two parts: the first one is the header
or method signature:
{
[Statement]
}
class MainClass
{
public static void main(String[ ] args) {
Stock st = new Stock(15, “John”); //creating
instance of class Stock
}
}