
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 9150 Articles for Object Oriented Programming

724 Views
RMI stands for Remote Method Invocation. It is a mechanism that allows an object residing/running in one system (JVM) to access/invoke an object running on another JVM. RMI is used to build distributed applications; it provides remote communication between Java programs. It is provided in the package java.rmi. To create an RMI Java application, you need to follow the steps given below - Step 1: Define the Remote Interface A remote interface provides the description of all the methods of a particular remote object. The client communicates with this remote interface. Therefore, you need to create an interface that extends ... Read More

407 Views
The URL class in the java.net package represents a web address or URL (Uniform Resource Locator), which points to a web resource such as a file, page, or directory in the World Wide Web (internet). The URL class provides various constructors, one of which accepts a String parameter (representing a URL) and constructs an object of the URL class. Reading From a URL You can read content from a URL using the openStream() method. This method opens a connection to the web address specified by the current URL object and gives you an InputStream object. The Java InputStream is an ... Read More

1K+ Views
While reading the contents of a file using a Java program, we may reach the end of the file abruptly; in such cases, EOFException (End Of File) is thrown. Especially, this exception occurs while reading data using the InputStream objects, such as DataInputStream. In other scenarios, a specific value will be thrown when the end of the file is reached. Why Does the EOFException Occur The EOFException occurs when a stream reaches the end of the file while reading its contents. If we consider the DataInputStream class, it provides various methods such as readBoolean(), readByte(), readChar(), etc, to read primitive ... Read More

5K+ Views
Static Methods and Static Blocks Static methods belong to the class and they will be loaded into memory along with the class; you can invoke them without creating an object. (using the class name as reference). Whereas a static block is a block of code with a static keyword. In general, these are used to initialize the static members. JVM executes static blocks before the main method at the time of class loading. Example The following example demonstrates the usage of static blocks and static methods in Java - public class Sample { ... Read More

3K+ Views
When we are working with those Java applications that handle JSON data, it is common that we find different date formats. It might happen that one field contains just the date, while another includes time and date, and even time zone. For handling this type of data Jackson library is very helpful. Jackson is a popular Java library that is used to convert Java objects into JSON and vice versa. And this process is called serialization and deserialization. To handle multiple date formats in a single class, Jackson provides an annotation called @JsonFormat. The@JsonFormat The @JsonFormat annotation helps Jackson ... Read More

1K+ Views
If you’ve been coding in Java for some time, you might have wondered why you can't make an enum extend another class. It seems like it should, but Java won't let you. Let's break down why this happens Enumeration in Java Enumeration (enum) in Java is a user-defined datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year, and seasons, etc. If we had to store all seven days of a week into one single variable then we might tend to use data ... Read More

4K+ Views
A JAR file is like a ZIP file but for Java code. For the packaging of multiple class files, Java provides a file format known as JAR (Java Archive). Typically, a JAR file contains .class files, images, text files, and libraries in a single file that are required to execute the Java application or library. This file format is used to distribute application software and libraries in Java. All the predefined libraries are available in this format. If you have any library in JAR format, to use it in your application, you either need to place it in the current folder ... Read More

1K+ Views
Java Virtual Machine is a program/software that runs Java applications. It takes Java bytecode (.class files) and converts the bytecode (line by line) into machine-understandable code, line by line so the processor can understand and execute it. JVM contains a module(components) known as a class loader. It is responsible for loading the program into memory and preparing it to run. Class Loader performs three main tasks - It Loads the class into the memory. ... Read More

3K+ Views
In Java, both abstract and final are class modifiers but they are completely opposite to each other. That's why Java class cannot be both abstract and final. Abstract class An abstract class in Java is a class that may contain both abstract methods (without implementation) and concrete methods (with implementation). If a class has even one abstract method, it must be declared abstract. You cannot create objects of an abstract class directly. If you want to use the concrete method in an abstract class you need to inherit the class, provide implementation to the abstract methods (if any) and ... Read More

2K+ Views
In general, while reading or writing data to a file, you can do so, from the start of the file. You cannot read/write from random position. The java.io.RandomAccessFile class in Java enables you to read/write data to a random-access file. This acts similar to a large array of bytes where the cursor known as file pointer works like an index. With the help of file pointer you can get the position of this pointer using the getFilePointer() method and set it using the seek() method. RandomAccessFile Class: Reading Files This class provides various methods to read and write data ... Read More