logo
logo
Sign in

Top 6 Java Concepts That Every Fresher Must Know

avatar
jack mathi
Top 6 Java Concepts That Every Fresher Must Know

Java is one of the most important technologies that generate a Multi career path and huge job opportunities in the IT sector. OOPs is the fundamental concept and practical implementation is very essential to get through knowledge in Java Programming. Concepts like Variables, Operations, Classes and Objects, Fields, Constructors, and Methods. To get the best job in Java domain, a fresher must have sound knowledge in these above said six foundation java concepts.

When you learn through hands-on exposure, it will help the freshers to get into the Java domain easily. Therewith in this blog, we would like to present the detailed insights of top-six Java concepts and we hope this will be useful for your further practices.

 

Variables in Java

Variables are the containers that hold the data to provide the value on the Java programming execution. It is the name of the memory location where the data stored in a computer register. Java variables are basically in three types such as local, instance, and static.

Local variables are declared inside the methods of a class which can only be used inside the method or particular classes and it can not be defined as static.

Instance variables, on the other hand, declared on the outside of the method of a class. The value of this instance variable is specific and can not be shared among other instances. This Instance variable can also not to be defined as static.

While Static variables are declared as static that can be accessed from all the instances and methods of the class. A static variable is stored permanently in the memory during the whole program execution.

 

Example of Java Variables

class vari_ex

{

int inst_var=50; //instance variable

static int st_var=100; //static variable

void method()

{

int loc_var=90; //local variable

}

}

 

Operators in Java

Java Programs have another important concept called Operators that must be known to the developer to create a full-fledged Java application. Because the operations are implemented to perform the calculations using operators such as +, -, *, /,? and so on. Java has the following

Types of operators to perform unique operations inside the program

Arithmetic Operators: Arithmetic Operators are used in Java to perform basic numeric operations such as multiplication (*), Division (/), Modulo (%), Addition, (+), and Subtraction (-).
Unary Operators: Unary operators are used to performing increments, decrements, and negate a value to the variables using only one operand. Unary Operators in Java are classified such as Unary minus (-), Unary plus (+), Increment (++), Decrements (--), and Logical not (!) operators.
Assignment Operator (=): This operator is used to assign a value to a variable in a Java program. It implies the right to left associative in assigning the value with “=” operator. It can be used with arithmetic operators to perform the operation and assign the value to the variable on the left at the same time. For example a + = 2 (it adds the original value of a to 2 and assign the result on the variable.
Relational Operators: Relational operators are used in Java to check the relationship among the operands such as equal, greater than or less than. These relational operators in java are classified as equal to(==), not equal to (!=), less than (<), less than or equal to (<=), greater than (>), and greater than or equal to (>=).
Logical Operators: Logical Operators are used in Java to perform “Logical End” and “Logical OR” of normal digital electronic functions. When Logical AND (&&) returns the value true if both conditions are true while Logical OR (||) returns true even if any one condition is true.
Ternary Operator: This is the shorthand version of the if-else statement which has three operands to execute the given statement with the use of (? and :). For Ex:? (a>b) ?a :b;
Bitwise Operator: Bitwise Operators are implemented in Java to perform number manipulation of individual bits. It will be used when our Java program has a query operation of the Binary indexed tree. To return the value with bit by bit AND, & Bitwise AND can be used, to return the value with bit by bit OR, |, Bitwise OR can be used, to return the value with bit by bit XOR, ^, Bitwise XOR can be used and to return one’s complement representation of input value, the unary operator can be used with ~, Bitwise Complement Operator.
Shift Operator: Shift operators are the operators used to shift the number to the left value to multiply or divide the number on the left. Left shift operator (<<) used to shift the number to left value with the given arithmetic operation and fills the 0. Signed Right Shift Operator (>>) used to assign the value to the right number and fills 0. And Unsigned right shift operator (>>>>) shifts the bits of the given number to the right and fills the 0 on the result.

Classes and Objects in Java

Classes in Java

Classes and Objects are the pillars of Object-Oriented Programming. Classes are the container of fields, constructors, methods, and attributes. Classes represent the attributes and defined by the users. It consists of the following components:

Modifiers: To define the class with accessibility such as private or public

Class Name: The name of the class which should start with Initial letter

Super Class (Optional): To proceed with any other extension for the particular class.

Interfaces (Optional): To implement any keyword that is separated by a comma

Body: The body of the class within braces { and }.

Objects in Java

Objects are the instances of a class that consists of “state” to reflect the properties,“behaviour” to represent method and “identity” that gives a unique name to interact with other objects.

 Constructors in Java

Constructors in Java are the block of code that initializes the new object. It resembles a method which does not have a return type. These are having the same name as a class name and invokes the class members for various usage.

Example of Java Constructors

public class MyClass

{

MyClass() //This is the constructor

{

}

}

 

Fields in Java

Fields are the data member of a class. It can be public, static, not static, and final. It represents the value such as text or numeric for providing information about accessibility and conversion.

 Example of Java Fields

public class Customer

{

final String field_sample = "Java Field"; // Fields of customer

int name;

}

 

Methods in Java

Methods in Java are the block of code that executes only when it is called. We can pass value or data as a parameter into methods. It is also referred to as functions and used to perform particular actions at the called time. It does not return any value.

Methods are used to reuse its code or members inside the program and it contains modifier, return type, method name, parameter list, exception list, a method body, and method signature.

Example of Java Methods:

import java.io.*;

class Sum

{

int add = 0;

public int addTwoInt(int a, int b)

{

// adding two integer value.

add = a + b;

//returning summation of two values.

return add;

}

}

 

Conclusion

We have given here the basic must-know concepts of Java and we hope this would be useful for your understanding with simple and understandable examples. Begin your Java programs with these fundamental concepts and learn more at our Java Training Institute in Chennai. We provide detail Java Training for the freshers to make you master in Java coding.

collect
0
avatar
jack mathi
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more