Raja has Published 760 Articles

How to handle the Runtime Exception in Java?

raja

raja

Updated on 06-Feb-2020 10:36:17

11K+ Views

The Runtime Exception is the parent class in all exceptions of the Java programming language that are expected to crash or break down the program or application when they occur. Unlike exceptions that are not considered as Runtime Exceptions, Runtime Exceptions are never checked.The Runtime Exception usually shows the programmer's ... Read More

What are the differences between StackOverflowError and OutOfMemoryError in Java?

raja

raja

Updated on 06-Feb-2020 10:17:07

739 Views

Whenever we run a java program, the operating system allocates some memory to JVM. JVM divides this memory into two parts. One is Stack memory and another is Heap memory. A stack is used for the execution of methods and heap is used to store the objects. When the Stack ... Read More

What are the differences between an application and an applet in Java?

raja

raja

Updated on 06-Feb-2020 10:13:32

1K+ Views

A Java program can be classified into two types, one is an Application and another is an Applet.ApplicationAn application is a stand-alone java program that runs with the support of a virtual machine in a client or server-side.A java application is designed to perform a specific function to run on ... Read More

Why the constructor name is same as the class name in Java?

raja

raja

Updated on 06-Feb-2020 10:09:33

2K+ Views

Every class object is created using the same new keyword, so it must have information about the class to which it must create an object. For this reason, the constructor name should be the same as the class name.Exampleclass MyConstructor{    public MyConstructor() {       System.out.println("The constructor name ... Read More

What are the differences between the Heap memory and the String Constant Pool in Java?

raja

raja

Updated on 06-Feb-2020 10:00:04

4K+ Views

Heap MemoryThe heap memory is a run time data area from which the memory for all java class instances and arrays is allocated.The heap is created when the JVM starts up and may increase or decrease in size while the application runs.The size of the heap can be specified using ... Read More

Scope and lifetime of variables in Java?

raja

raja

Updated on 06-Feb-2020 09:24:32

7K+ Views

Instance VariablesA variable which is declared inside a class and outside all the methods and blocks is an instance variable. The general scope of an instance variable is throughout the class except in static methods. The lifetime of an instance variable is until the object stays in memory.Class VariablesA variable ... Read More

How to implement DoublePredicate using lambda and method reference in Java?

raja

raja

Updated on 16-Jan-2020 10:04:48

153 Views

DoublePredicate is a built-in functional interface defined in java.util.function package. This interface can accept one double-valued parameter as input and produces a boolean value as output. DoublePredicate interface can be used as an assignment target for a lambda expression or method reference. This interface contains one abstract method: test() and three default methods: and(),  or() and ... Read More

What are the rules to follow while using exceptions in java lambda expressions?

raja

raja

Updated on 20-Dec-2019 08:36:16

3K+ Views

The lambda expressions can't be executed on their own. It is used to implement methods that have declared in a functional interface. We need to follow a few rules in order to use the exception handling mechanism in a lambda expression.Rules for Lambda ExpressionA lambda expression cannot throw any checked ... Read More

How to pass a lambda expression as a method parameter in Java?

raja

raja

Updated on 19-Dec-2019 13:09:20

6K+ Views

A lambda expression is an anonymous or unnamed method in Java. It doesn't execute on its own and used to implement methods that are declared in a functional interface. If we want to pass a lambda expression as a method parameter in java, the type of method parameter that receives ... Read More

What kind of variables can we access in a lambda expression in Java?

raja

raja

Updated on 11-Dec-2019 12:30:52

754 Views

The lambda expressions consist of two parts, one is parameter and another is an expression and these two parts have separated by an arrow (->) symbol. A lambda expression can access a variable of it's enclosing scope. A Lambda expression has access to both instance and static variables of it's enclosing class and also it can ... Read More

Advertisements