Java Class
A class is like a blueprint, it contains different kinds of things such as variables,methods,constructors etc.
Let's see how to declare a class.
A class name should start from a capital letter.
Ex: class HelloWorld{}
Accessibility of variables can be changed according to Access Modifiers. There are four types of access modifiers.
Let's see how to declare a class.
A class name should start from a capital letter.
Ex: class HelloWorld{}
Accessibility of variables can be changed according to Access Modifiers. There are four types of access modifiers.
- Private - visible only within the class.
- Protected - visible to any other class in the same package.
- Public - visible to any class.
- Default - same as protected. Visible to any other class in the same package.
(+) mark is used to denote public variables.
Ex:
-name:String
private String name;
+mark:int
public int mark;
Comments
Post a Comment