
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7442 Articles for Java

3K+ Views
No, we cannot write any statements in between try, catch and finally blocks and these blocks form one unit. The functionality of try keyword is to identify an exception object and catch that exception object and transfer the control along with the identified exception object to the catch block by suspending the execution of the try block. The functionality of the catch block is to receive the exception class object that has been sent by the try and catch that exception class object and assigns that exception class object to the reference of the corresponding exception class defined in the catch block. The finally blocks are ... Read More

3K+ Views
The Recursion and Iteration both repeatedly execute the set of instructions. Recursion is when a function calls itself repeatedly. The iteration is when a loop repeatedly executes until the controlling condition becomes false. The primary difference between recursion and iteration is that recursion repeats the statement in a function, whereas iteration is applied to the set of instructions that we want to execute repeatedly. In this article, we will compare recursion and iteration in Java and discuss the difference between them. Before we proceed, it is important to understand these two concepts with an example. Recursion in Java Recursion is ... Read More

6K+ Views
A block of statements that the program control can never reach under any circumstances can be called an unreachable block. Java does not support unreachable blocks, such code will cause a compile-time error. Any code that is written but never executed is considered unnecessary by the Java compiler. In this article, we will discuss unreachable catch blocks in Java. But, before that, let's understand what is a catch-block in Java. The catch Block in Java The catch block is written just after the try block and cannot have any code between them. It is an exception handler and contains code ... Read More

5K+ Views
Both String class and Char[] array in Java are used to store textual data. However, Strings are immutable, which means you can't make changes to a String once defined, and the char[] array is not immutable. In the official documentation of Java Cryptography Architecture, it is clearly written that String objects are not suitable for storing sensitive data, such as passwords, SSN, etc. Use a char array instead, as it is more secure than String. This article will help you understand why char[] array is used to store sensitive data. Char Array is more secure than String Let's discuss why ... Read More

15K+ Views
Every Java object has two very important methods, equals() and hashCode(), and these methods are designed to be overridden according to their specific general contract. Since the Object class is the parent class of every class, the default implementation of the equals() and hashCode() methods is already present in each class. However, we need to override these methods based on the requirement. Let's discuss the contract between equals() and hashCode() methods in Java. But before that, we need to understand these methods. The hashCode() Method The hashCode() method returns an integer value, which is referred to as the hash code value ... Read More

16K+ Views
In object-oriented programming, coupling is a term used to describe the level of dependency each class or component of an application has on another. Tight coupling in Java means features of different classes and objects have high dependence on one another, whereas Loose coupling means components have very low or no dependency on one another. This article explains how tight coupling is different from loose coupling in Java. Tight Coupling in Java In tight coupling, if the implementation of one class changes, the dependent class might also need to be changed. It makes Java code less flexible and more difficult ... Read More

444 Views
The java.lang.Class is one of the most important class in Java and it can provide several utility methods like getClass(), forName() which is used to find and load a class. It can also provide methods like Class.newInstance() which is the backbone of reflection and allow us to create an instance of a class without using new() operator.Importance of java.lang.ClassInstances of the class Class represent classes, interfaces, enum and annotation in a running Java application.Whenever a java file is compiled, the compiler will insert a public, static, final field named Class of the type java.lang.Class into generated .class fileEach and every class exposes its code in the form of an ... Read More

12K+ Views
Immutable objects are those objects whose states cannot be changed once initialized. Sometimes it is necessary to make an immutable class as per the requirement. For example, All primitive wrapper classes (Integer, Byte, Long, Float, Double, Character, Boolean and Short) are immutable in Java. String class is also an immutable class.To create a custom immutable class we have to do the following stepsDeclare the class as final so it can’t be extended.Make all fields private so that direct access is not allowed.Do not provide setter methods (methods that modify fields) for variables, so that it can not be set.Make all mutable ... Read More

167 Views
In C++ and Java, there are another type of loop called foreach loop. This is not present in C. This loop has introduced in C++11 and Java JDK 1.5.0. The advantage of this loop is that, it can access the elements very quickly without performing initialization, testing and increment/decrement. This loop is used to access every element in one array or some containers. This loop is known as foreach but to denote this loop we have to use ‘for’ keyword. The syntax is different than normal for and foreach.for(datatype item : Array) { }Let us see some examples of foreach ... Read More

295 Views
The exception handling feature is present almost any object oriented languages nowadays. In C++ and Java also we can get this kind of feature. There are some similarities between exception handling in C++ and exception handling in Java, like in both languages we have to use the try-catch block. Though there are some difficulties also. These are like below −In C++, we can throw any type of data as exception. Any type of data means primitive datatypes and pointers also. In Java we can only throw the throwable objects. Subclasses of any throwable class will also be throwable.Example Live Demo#include ... Read More