Category: java-basics
Method Overloading in Java
In Java you can have two or more methods having the same name with in the same class provided their arguments differ in either type or number. These types of methods are called overloaded methods and the process is known as method overloading in Java. Method overloading in Java –…
super in Java With Examples
Super keyword in Java is used to refer to the immediate parent class of the sub class. You can use super keyword in Java in following ways- You can invoke the constructor of the parent class, doing that using super makes your code more compact and classes are better encapsulated.…
static in Java With Examples
Static keyword in Java is used to create variables and methods that are associated with the class rather than with any object of the class. Table of contents Static in Java static variables in Java Static variables usage static methods in Java static method access restrictions Static method usage Static…
Java Ternary Operator With Examples
In the post conditional operators in Java we talked about the Conditional-AND and Conditional-OR operators, here we’ll talk about another conditional operator known as ternary operator in Java (?:). Ternary operator uses three operands thus the name ternary operator and it can be used in place of if-else statement or…
Java Conditional Operators With Examples
There are two conditional operators in Java- && (known as Conditional-AND) and || (known as Conditional-OR). Both Conditional-AND (&&) and Conditional-OR (||) operators in Java perform operations on two boolean expressions and return a boolean value. Conditional-AND– In case of && operator in Java if any of the two boolean…
Java Operators: Equality And Relational
The equality and relational operators in Java are used to determine if value of one operand is greater than, less than, equal to, or not equal to the value of another operand. These operators return a boolean value determining whether a comparison is true or false. For example- if(5 >…
Java Operators: Assignment, Arithmetic And Unary
This post shows the assignment, arithmetic and unary operators available in Java. Table of contents Assignment operator in Java Arithmetic operators in Java Java arithmetic operators example Overloaded + operator for String Compound assignment in Java Java Compound assignment example Unary operators in Java Java Unary operators example Increment and…
File Name Same as Class Name in Java
If you are reading the beginning chapter of any Java book or seeing any first Java program example online, one thing you will notice is that file name should be same as the class name in Java. In this post we’ll see how true is the statement that the file…
Why main Method static in Java
When you write any Java program it’s starting execution point is the main method which has a form as following. Public static void main(String[] args) Given this signature of main method in Java the question arises why main method is public, void and static in Java. It is asked quite…
Method Overloading in Java
In Java you can have two or more methods having the same name with in the same class provided their arguments differ in either type or number. These types of methods are called overloaded methods and the process is known as method overloading in Java. Method overloading in Java –…
super in Java With Examples
Super keyword in Java is used to refer to the immediate parent class of the sub class. You can use super keyword in Java in following ways- You can invoke the constructor of the parent class, doing that using super makes your code more compact and classes are better encapsulated.…
static in Java With Examples
Static keyword in Java is used to create variables and methods that are associated with the class rather than with any object of the class. Table of contents Static in Java static variables in Java Static variables usage static methods in Java static method access restrictions Static method usage Static…
Java Ternary Operator With Examples
In the post conditional operators in Java we talked about the Conditional-AND and Conditional-OR operators, here we’ll talk about another conditional operator known as ternary operator in Java (?:). Ternary operator uses three operands thus the name ternary operator and it can be used in place of if-else statement or…
Java Conditional Operators With Examples
There are two conditional operators in Java- && (known as Conditional-AND) and || (known as Conditional-OR). Both Conditional-AND (&&) and Conditional-OR (||) operators in Java perform operations on two boolean expressions and return a boolean value. Conditional-AND– In case of && operator in Java if any of the two boolean…
Java Operators: Equality And Relational
The equality and relational operators in Java are used to determine if value of one operand is greater than, less than, equal to, or not equal to the value of another operand. These operators return a boolean value determining whether a comparison is true or false. For example- if(5 >…
Java Operators: Assignment, Arithmetic And Unary
This post shows the assignment, arithmetic and unary operators available in Java. Table of contents Assignment operator in Java Arithmetic operators in Java Java arithmetic operators example Overloaded + operator for String Compound assignment in Java Java Compound assignment example Unary operators in Java Java Unary operators example Increment and…
File Name Same as Class Name in Java
If you are reading the beginning chapter of any Java book or seeing any first Java program example online, one thing you will notice is that file name should be same as the class name in Java. In this post we’ll see how true is the statement that the file…
Why main Method static in Java
When you write any Java program it’s starting execution point is the main method which has a form as following. Public static void main(String[] args) Given this signature of main method in Java the question arises why main method is public, void and static in Java. It is asked quite…