assignment - HinaUmer123/assignment GitHub Wiki

=head3 =head3 Class/static variables: Class variables also known as static variables are declared with thestatic keyword in a class, but outside a method, constructor or a block. Static variables are rarely used other than being declared as constants. Constants are variables that are declared as public/private, final and static. Constant variables never change from their initial value. Static variables are stored in static memory. It is rare to use static variables other than declared final and used as either public or private constants.

=head3 =head3 Showing Local Variable

public class LocalVar { public static void main(String args[]) { int localvariable = 101; System.out.print(localvariable); } } =head3 =head3 =head3 Showing the Class Variable

public class ClassVar { private static int classVariable;

public static void main(String args[]) {
  classVariable = 101;
  System.out.print(classVariable);
}
}        

=head3 =head3 Types of java constructors There are two types of constructors: Default constructor (no-arg constructor) Parameterized constructor

=head3 =head3 Default constructor

A Constructors that have no any parameters is known as default constructor. Why use parameterized constructor?

=head3 =head3 Parameterized constructor it is used to provide different values to the distinct objects.

=head3 =head3 public access modifier Fields, methods and constructors declared public (least restrictive) within a public class are visible to any class in the Java program, whether these classes are in the same package or in another package. =head3 =head3 =head3 private access modifier The private (most restrictive) fields or methods cannot be used for classes and Interfaces. It also cannot be used for fields and methods within an interface. Fields, methods or constructors declared private are strictly controlled, which means they cannot be accesses by anywhere outside the enclosing class. A standard design strategy is to make all fields private and provide public getter methods for them.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 12:

Non-ASCII character seen before =encoding in 'thestatic keyword'. Assuming UTF-8

⚠️ **GitHub.com Fallback** ⚠️