Maruthi Krishna has Published 558 Articles

Can we assign values to final arrays in Java?

Maruthi Krishna

Maruthi Krishna

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

550 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

3K+ 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

941 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

1K+ 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

5K+ 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

3K+ 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

Is it possible to throw exception without using "throws Exception" in java?

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 11:02:55

4K+ Views

When an exception occurs in Java, the program terminates abnormally and the code past the line that caused the exception doesn’t get executed.To resolve this you need to either wrap the code that causes the exception within try catch ot, throw the exception using the throws clause. If you throw ... Read More

What happens when you declare a method/constructor final in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 08-Aug-2019 13:23:52

488 Views

Whenever you make a method final, you cannot override it. i.e. you cannot provide implementation to the superclass’s final method from the subclass.i.e. The purpose of making a method final is to prevent modification of a method from outside (child class).Still, if you try to override a final method a compile ... Read More

How to find If a given String contains only letters in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 12:13:04

2K+ Views

To verify whether a given String contains only characters −Read the String.Convert all the characters in the given String to lower case using the toLower() method.Convert it into a character array using the toCharArray() method of the String class.Find whether every character in the array is in between a and ... Read More

Comparing Strings with (possible) null values in java?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:59:25

6K+ Views

Strings in Java represents an array of characters. They are represented by the String class.Using compareTo() methodThe compareTo() method of the String class two Strings (char by char) it also accepts null values. This method returns an integer representing the result, if the value of the obtained integer is −0: ... Read More

Advertisements