Java With Us
Home   |   Tutorial   |   Programs  

Java Tutorial

Introduction to Java
Hello World Program
Variables and Data types
More about data types
Displaying text using print and println
Displaying text using printf
Java Comments
Naming conventions for Identifiers
Mathematical operations in Java
Taking input from the user

Classes and Objects
Introduction to object oriented programming
The constituents of a Class
Creating objects and calling methods
Get and Set Methods
Default constructor provided by the compiler
Access Specfiers
Scope and lifetime of Variables
Call by value and Call by Reference

A few more topics
Casting
Class as a reference data type
Constants or literals
Final variables
Increment and decrement operators
Manipulating Strings
Operators
Overloading constructors and methods
Static methods and variables
The Java API
The Math class
this keyword
Wrapper classes

Control Structures
Control Statements
Repetition statements
Nested loops
Formulating algorithms
Branching Statements

Arrays
Arrays introduction
Processing arrays using 1oops
Searching and sorting arrays
Array of objects
Multi dimensional arrays
Taking input as command line arguments
Using ellipsis to accept variable number of arguments

Inheritance
Inheritance introduction
Relation between a super class and sub class
Final classes and methods
The protected access specifier
Class Object

Polymorphism
Introduction
Interfaces
Packages
Abstract classes and methods

Exception handling
Exception handling introduction
Exception hierarchy
Nested try catch blocks
Throwing exceptions


Naming Conventions for Identifiers

If you have observed every program written by us closely, you would have noticed certain similarities in the way we have named our classes and variables. We always started our class name with a capital letter (HelloWorld, Addition). On the contrary, we have started a variable name with a small letter and then capitalised every subsequent word (firstNumber, secondNumber, result). These are the naming conventions which are followed by all. Following these conventions also makes a language simpler. If you remember, you have been said earlier while discussing about the case sensitivity of Java that there is no need to panic about what words are to be capitalised and what shouldn't be capitalised. You now need not spend time thinking if 's' in System should be capitalised or not. Since it is the name of a class, the 's' has a need to be stated in capitals. These conventions have been followed in the pre-defined classes of Java too. These classes together form the java API. We shall learn more about the PAI later on. For now, we shall see the conventions that are followed while naming classes, variables and methods.

The starting letter of each word in a class name is capitalised. All other letters are written in lower case. Examples: Addition, Car, HelloWorld

Method names follow a convention similar to that of class names except that the first letter is not capitalised. Till now, we have come across only one method- main. We shall shortly see how we can define as many methods as we want with any name that we wish. Examples of some method names are main, drawShape, printString, add.

Variables follow conventions similar to that of method names. However, when we use an identifier in a class, we can easily say if it is a method name or a variable name because of the parentheses that are placed adjacent to method name. Remember that when we had written result in the print() statement, we haven't appended a pair of parentheses at the end.

System.out.println ("Result:"+ result);

However, when we have called the print(), println() and printf() methods, we have a pair of parentheses at the end in which we have written the arguments. Not all methods require arguments. We shall study more about methods in detail in a later chapter.

In addition to classes, variables and methods, we also have packages, final variables and interfaces. The naming conventions for them will be stated when we come across them in our study.

Note that following conventions is not mandatory. You can name your class as 'helloWorld' or 'HellOWoRLd' and the program still works. But following the conventions makes your program looks professional and people going through your program wouldn't face any difficulties trying to comprehend whether a particular identifier is a variable, a class, an interface or some other entity.

Privacy Policy