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.

  1. Private - visible only within the class.
  2. Protected - visible to any other class in the same package.
  3. Public - visible to any class.
  4. Default - same as protected. Visible to any other class in the same package.
(-) mark is used to denote private variables.
(+) mark is used to denote public variables.

Ex:
-name:String 
      private String name;
+mark:int
      public int mark;




Comments

Popular posts from this blog

Programming with Java

C- Control Structures

C - Functions