JAVA

Lambda Expression | Java

Introduction Lambda expression was included in Java SE 8. It provides a clear and concise way to represent one method interface using an expression. The Lambda expression is used to provide the implementation of an interface which has functional interface. It saves a lot of code. Java lambda expression is [...]

2019-08-07T23:26:43+05:30Categories: Programming|Tags: |

Fractional parts from a double value | Java

Program to get whole and fractional parts from a double value public class FarctionalPart { public static void main(String[] args) { // Method 1 double value = 12.56; double fractional_part = value % 1; double integral_part = value - fractional_part; // Method 2 String numberD = String.valueOf(value); // Fractional part [...]

2019-02-06T10:35:18+05:30Categories: Programming|Tags: |

Abstraction in OOPS

Abstraction is a process of hiding the implementation details from the user, only the functionality will be provided to the user. In other words, the user will have the information on what the object does instead of how it does it. Through the process of abstraction, a programmer hides all [...]

2024-05-11T14:58:06+05:30Categories: Programming|Tags: |

Difference Between Interface and Abstract Class

Difference Between Interface and Abstract Class Interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior. A class can implement multiple interfaces but it can extend only one abstract class. Variables declared in interface is by default final. An  abstract class [...]

2019-03-24T18:08:53+05:30Categories: Programming|Tags: |

Scope and Lifetime of Variables

The scope of a variable defines the section of the code in which the variable is visible. As a general rule, variables that are defined within a block are not accessible outside that block. The lifetime of a variable refers to how long the variable exists before it is destroyed. [...]

2018-09-16T17:14:18+05:30Categories: Programming|Tags: |

Stack vs. Heap Memory Allocation | Java

Introduction Java applications need a certain amount of RAM on a computer to run. Each time an object or variable is declared, it needs more RAM. Simply designating enough memory to hold every value declared and run each method would lead to a bloated application. The Java Virtual Machine (JVM) [...]

2019-11-26T21:43:29+05:30Categories: Programming|Tags: |

Thread and Runnable | Java

Introduction Every thread in Java is created and controlled by a unique object of the java.lang.Thread class. When a standalone application is run, a user thread is automatically created to execute the main( ) method. This thread is called the main thread. In Java, we can implement threads in one [...]

2019-08-16T15:34:35+05:30Categories: Programming|Tags: |

Static keyword in Java

The static keyword is used in java mainly for memory management. It is used with variables, methods, blocks and nested class. It is a keyword that are used for share the same variable or method of a given class. No object needs to be created to use static variable or [...]

2018-09-16T21:00:38+05:30Categories: Programming|Tags: |

Immutable class in Java

Immutable class means that once an object is created, we cannot change its content. In Java, all the wrapper classes (like String, Boolean, Byte, Short) and String class is immutable. We can create our own immutable class as well. Following are the requirements: Class must be declared as final (So [...]

2018-09-01T21:18:11+05:30Categories: Programming|Tags: |

ValueOf() Method Of Wrapper Classes In Java

Every wrapper class in java has 3 forms of valueOf method. They are, A valueOf() method which takes primitive type as an argument A valueOf() method which takes String type as an argument A valueOf() method which takes two arguments. One is String type and another one is int type. [...]

2018-06-09T13:31:59+05:30Categories: Programming|Tags: |
Go to Top