Category: Java Basic

Java naming conventions

Java naming conventions are “rules” which a developer decide to use in his code. These rules are meant to make your code more understandable and easier to read for other developers. At first SUN, and then Oracle conventions to name the different Java types (packages, classes, interfaces, methods, variables and constants). Some of the naming

How to execute a Java class using the command prompt

In your role as a developer, you will use an Integrated Development Environment (IDE) to compile and run your java application. However, you must know that Java Development Kit (JDK) provides an application which compiles the java code and another application to run java applications. You can call this application from the command line. To

Understand the main method of a Java class

The  main method is the start point of any Java executable application. It has the signature : [crayon-68d33fa522940765367831/] or, [crayon-68d33fa52294a580202592/] The following rules apply when creating the main method : The main method must be marked as public and static. The order in which public and static may appear doesn’t matter; The name of the

Java non-access modifiers

In this section I will let you know only about the non-access modifiers which are covered by the Java Certification Oca 7 Programmer I exam : abstract; final; static. A Java developer uses non-access modifiers to assign special privileges, responsibilities, and behavior to the Java types. Usually, non-access modifiers are used to change the default properties

Java access modifiers

In Java, access modifiers control the accessibility of a class or an interface by other classes and interfaces. It also controls the accessibility of the class methods and variables. By using the appropriate access modifiers, a developer can limit access to his classes and interfaces and their members. From the previous post we remember that

Introduction to Java modifiers

Java modifiers are split into two categories : Access modifiers; Non-access modifiers. Access modifiers are the “responsible” for determining the accessibility of a class, an interface and their methods and variables. In Java there are three access modifiers : public; protected; private. and, four access levels : public; protected; private; default. Non-access modifiers are used to assign

Introduction into Java interfaces

Java, defines an interface as : a group a related methods and constants which specifies a contract for a class to implement. The definition of an interface starts with the keyword interface. In Java 7, an interface can define only abstract methods and constants. Interfaces methods cannot contain any implementation and are implicitly public. The variables of an

Constructors in Java

Basically, a class constructor is a special method used to create an object of a class, and initialize its instance variable. A class can define multiple constructors with different sets of method parameters. Remember : A constructor must match the name of the class and cannot declare a return value (not even void). Here are the

Methods in Java

In Java Programming Language, methods may or may not accepts parameters. The methods in Java, came in two flavors : Instance methods. Are used to manipulate instance variables. Class methods. Also called static methods and are used to manipulate the static variables.

Variables in Java

Java Programming languages defines four flavors of variables: Instance variables (also known as non-static variables). They are declared inside a Java class, but outside of the scope of a method. Their values are unique to each instance (object) of the class. Class variable (also known as static variables). It can be said that a class