Maruthi Krishna has Published 951 Articles

Defining generic method inside Non-generic class in Java

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 12:59:31

2K+ Views

You can write a single generic method declaration that can be called with arguments of different types. Based on the types of the arguments passed to the generic method, the compiler handles each method call appropriately. Following are the rules to define Generic Methods −All generic method declarations have a ... Read More

Restrictions while declaring a generic (type) in Java

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 12:57:21

952 Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class ... Read More

How to import classes from within another directory/package in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 12:37:48

6K+ Views

In Java classes and interfaces related to each other are grouped under a package. The package is nothing but a directory storing classes and interfaces of a particular concept. For example, all the classes and interfaces related to input and output operations are stored in the java.io package.There are two ... Read More

Traversing contents of a hash map in Java

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 12:33:45

570 Views

A map is a collection in Java which stores key-value pairs. The keys of this must not be null and each key should point to only one value. It is represented by the Map interface of java.util package. There are various classes which provide implementation to this interface.The HashMap is ... Read More

Can we assign values to final arrays in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 12:26:23

363 Views

The array is a container that can hold a fixed number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. The following are the important terms to understand the concept of Array.Element − Each item ... Read More

Shadowing of static methods in Java

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 12:12:02

2K+ Views

When superclass and the subclass contain the same instance methods including parameters, when called, the superclass method is overridden by the method of the subclass.Example Live Democlass Super{    public void sample(){       System.out.println("Method of the Super class");    } } public class MethodOverriding extends Super {    public ... Read More

Checked Vs unchecked exceptions in Java programming.

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 11:57:14

710 Views

Checked exceptionsA checked exception is an exception that occurs at the compile time, these are also called as compile-time exceptions. These exceptions cannot simply be ignored at the time of compilation; the programmer should take care of (handle) these exceptions.When a checked/compile time exception occurs you can resume the program by ... Read More

Out of memory exception in Java:

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 11:31:01

901 Views

Whenever you create an object in Java it is stored in the heap area of the JVM. If the JVM is not able to allocate memory for the newly created objects an exception named OutOfMemoryError is thrown.This usually occurs when we are not closing objects for long time or, trying ... Read More

Why do we need generics in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 11:29:28

4K+ Views

Reference typesAs we know a class is a blue print in which we define the required behaviors and properties and, an interface is similar to class but it is a Specification (containing abstract methods).These are also considered as datatypes in Java, unlike other primitive datatypes a literal of these kind ... Read More

How to check if a file is readable, writable, or, executable in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 11:19:46

2K+ Views

In general, whenever you create a file you can restrict/permit certain users from reading/writing/executing a file.In Java files (their abstract paths) are represented by the File class of the java.io package. This class provides various methods to perform various operations on files such as read, write, delete, rename, etc.In addition, ... Read More

Advertisements