Maruthi Krishna has Published 870 Articles

Can Enum extend any class in java?

Maruthi Krishna

Maruthi Krishna

Updated on 21-Apr-2025 15:13:34

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 ... Read More

How to read a .txt file with RandomAccessFile in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 21-Apr-2025 12:59:09

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 ... Read More

What are the restrictions imposed on a static method or a static block of code in java?

Maruthi Krishna

Maruthi Krishna

Updated on 18-Apr-2025 18:32:45

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 ... Read More

How many types of memory areas are allocated by JVM in java?

Maruthi Krishna

Maruthi Krishna

Updated on 18-Apr-2025 18:17:44

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 ... Read More

How to handle EOFException in java?

Maruthi Krishna

Maruthi Krishna

Updated on 18-Apr-2025 18:14:21

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 ... Read More

How to send data over remote method in java?

Maruthi Krishna

Maruthi Krishna

Updated on 16-Apr-2025 17:02:51

720 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 ... Read More

What are the key steps in read/write from/to a URL connection in java?

Maruthi Krishna

Maruthi Krishna

Updated on 16-Apr-2025 16:29:17

400 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 ... Read More

How to make an ArrayList read only in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 16-Apr-2025 11:20:17

899 Views

A collection is an object that holds a reference to other objects. A Java array list is one of the collections. it is a resizable array and is represented by the class named ArrayList. This java.util.Collections class provides methods to manipulate the collection objects in Java. We can make an ... Read More

JavaFX example to create area chart with multiple series

Maruthi Krishna

Maruthi Krishna

Updated on 18-Dec-2024 16:16:13

390 Views

The area chart accepts a series of data points (x, y) as input values, connects them using a line, and maps the area between the obtained line and the axis. In JavaFX, you can create an area chart by instantiating the javafx.scene.chart.AreaChart class. While instantiating this class you must pass ... Read More

Pattern UNIX_LINES field in Java with Examples

Maruthi Krishna

Maruthi Krishna

Updated on 08-Aug-2024 12:56:52

296 Views

This flag enables Unix lines mode. In the Unix lines mode, only '' is used as a line terminator and ‘\r’ is treated as a literal character. Example 1 import java.util.regex.Matcher; import java.util.regex.Pattern; public class LTERAL_Example { public static void main(String[] args) { ... Read More

Advertisements