In this article I will give summary of all the java basic concepts. For detailed information click the “learn more about…..” links which are available after the summary of each java basic concepts.
Before directly jumping into the Java basic concepts, first let’s know why Java is a popular programming language. To know why Java is popular, you have to learn about the Java features also known as Java buzzwords.
1) Simple: Java designers built the language in such way that it is very easy to write programs using Java’s syntax. It also allows experienced programmers who know C and C++ to move away to Java more quickly since Java’s syntax was derived from C and object orientation features were derived from C++. If you already know about object orientation principles it will be much easier to write programs using Java.
2) Object Oriented: Java is a object oriented programming language which allows the users to solve the given problem in terms of classes and objects. Writing the solution in terms of classes and objects produces code which is easier to write, maintain and reuse.
3) Robust: Errors in Java programs does not crash the virtual machine or hurt the underlying operating system. Several built-in Java features help the users to create reliable programs.
Java is a strongly typed language which requires the programmer to declare the type of a variable before using it. Java also has built-in memory management mechanism known as garbage collector.
Java also provides exception handling to handle runtime errors. Pointers available in C/C++ are not supported by Java which may lead to memory errors.
4) Multithreaded: Java allows us to create interactive programs, which requires threads. Multithreading enables a program to carry out multiple tasks at the same time. For example, consider listening to music and writing something on a piece of paper at the same time.
Java provides multiprocess synchronization primitives so that a programmer can be free from the worries of providing complex synchronization solutions.
5) Architecture Neutral: Java compiler generates bytecode which when run on any machine gives the same output. Java’s goal is to enable programmers to develop programs which has WORA (Write Once, Run Anywhere) property.
6) Interpreted: The bytecode generated by the Java compiler goes as input to the Java Virtual Machine (JVM) which is the runtime engine that interprets bytecode into machine code (0’s and 1’s) line by line. Interpretation speeds up the development process and simplifies debugging process.
7) High performance: Many virtual machines use a JIT (Just-In-Time) compiler that converts the bytecode into platform-specific instructions as the program executes. This helps to improve the performance of the Java programs.
8) Distributed: Java provides libraries for handling TCP/IP, FTP and other network protocols which enables programmers to easily develop distributed applications. Java also provides Remote Method Invocation (RMI) which enables a program to access methods across a network.
9) Dynamic: Java programs maintain non-trivial amount of run-time type information which is used to verify and access objects at run time. This allows to dynamically link small fragments of bytecode during execution of the application.
10) Portable: Portability is achieved through Java’s architecture neutrality and through a strict definition of the language. For example, Java’s integer primitive type always means a signed 2’s complement 32-bit integer. Whereas in C/C++, integer can be unsigned and its size varies according to the system’s register size.
11) Secure: Java’s sandbox security model available in applets prevents the Java program from accessing the resources of the user’s system. This prevents malicious programs to gain access to sensitive information available on the user’s system.
If you are interested in learning Java’s evolution (Genesis) or version changes click this link: Evolution of Java
To learn the life cycle of a Java program, click this link: Life cycle of a Java program
By this time you might be bored to hell with all this theoretical stuff. For a breather, let’s look at how to write a simple Java program, compile and execute it. Click this link to know how to do it: create, compile and execute a Java program.
Java Basic Concepts
Java Virtual Machine: The run-time engine required for executing Java bytecode is provided by JVM. Read more about Java Virtual Machine here.
Structure of a Java program: What are the fundamental elements/sections that make up a Java program? Read more about structure of a Java program here.
Classes and Objects: Every Java program consists of at least one class and it is common for a class to have objects. Read more on classes and objects here.
Comments: A comment is a line or lines of text which is used to provide explanations and other useful information. Read more on comments here.
Variables: A variable is a memory location in which you can store different values based upon your requirement. Read more on variables here.
Data types: Java is a strongly typed language i.e., you have to specify the type of value you are going to store in a variable before declaring it. The mechanism which allows us to specify the type of values a variable holds, is the data type. Read more on data types here.
Literals: A literal is a constant value that can be assigned to a variable or used in an expressions. Read more on literals here.
Scope and life time of variables: The scope of a variable determines in which locations is a variable accessible and the life time determines the time until which a variable is alive. Read more on scope and lifetime of variables here.
Methods: A Java class can contain fields (variables) and methods (functions) which are used to perform computations on fields. Read more about methods here.
Operators: It is common in programs to perform different operations (like addition, subtraction, etc…) on variables. In Java we have a wide variety of operators to perform various operations. Read more on Java operators here.
Type conversion and Casting: In Java you might want to convert one type of value to another type. You can do conversions using type conversion or casting. Read more on type conversion and casting here.
Expressions: An expression is a combination of literals, variables and operators which evaluate to a single value. Read more on expressions here.
Control Statements: While writing programs you might want to make decisions or there might be need to perform the same task again and again. For doing such things, we need control statements. Read more about control statements here.
Arrays: An array is a collection of homogeneous elements referenced with the same name. Read more about arrays here.
Constructors: A constructor is a special method which will have the same name as class name. Read more about constructors here.
Overloading: In Java, one of the way to achieve polymorphism is by overloading. Read more on overloading here.
Parameter Passing: In Java, we can pass parameters in two ways, namely pass-by-value and pass-by-reference. Read more on parameter passing techniques here.
Access Control: In Java we restrict the scope of class members and even the scope of class itself using access control mechanisms. Read more about access specifiers here.
this Keyword: The this keyword in Java is used to access the current objects members. Read more about this keyword here.
static Keyword: The static can be used to create variables, methods and inner classes. Read more on static keyword here.
final Keyword: The final keyword has various uses in Java. One common use is to create constants. Read more on final keyword here.
Garbage Collection: Unlike C and C++, there is no need for the programmer to worry about the memory management because of garbage collector in Java. Read more on garbage collection in Java here.
Recursion: A method calling itself within its method definition is known as recursion. Read more on recursion here.
Command Line Arguments: The information passed along with program’s name at the command line are known as command line arguments. Read more on command line arguments here.
Variable-Length Arguments (Varargs): The feature in Java which allows methods to specify variable number of arguments is known as varargs. Read more on varargs here.
Nested Classes: A class which is defined as a member of another class definition is known as a nested class. Read more on nested classes here.