Saturday , August 19 2017
Home / JAVA / CORE JAVA

CORE JAVA

 

Core Java Tutorials

Java Variable Types

The value of a variable is bound to a particular instance is called instance variable. That value can be varied from one object to another. For every object a separate copy of instance variable will be created in the memory, and the scope of that variable will be the exact scope of the object.

Java Static Variable, Method, Block and Class

If a method that declared by using the static keyword, then we say that method is a static method. The extreme example for a static method in Java is main method. Static methods are called without using the object. We can directly call the static methods from the main method.

Increment and decrement operators in Java

Increment and decrement operators are unary operators. We can apply these operators only on single operand, that is why we call them as unary operators. we can apply these operators on all primitive types except boolean.

Reference types in Java (Strong, weak, soft, phantom)

Garbage collection is a sophisticated Java feature that takes care of automatic deallocation of objects that are not in use. The garbage collection mechanism reclaims memory from an object when there are no active references to that object.

Technical Features of Java programming

The Java programming language offers a blend of traditional programming features and innovative concepts. The primary characteristics and syntax of Java follows the features of C and C++ to a certain extent.

JDK, JRE, JVM Differences

In Java documentation, we frequently come across the terms JVM, JRE, and JDK. A clear understanding of these terms is essential to grasp their usage and differences. Let’s examine each of these terms in detail and then identify their differences.

Java Heap and Garbage Collection

When we are creating the array or class instance in the Java application platforms the new object memory is allocated from the single heap. The main reason behind it is that there is a single heap present inside the Java virtual machine as well as the threads shared with it.

public static void main(String args[])

In Java main method is an entry point of the any core Java program. Why I am mention specifically as core Java program is, in other than the core Java programs like Servlets, applets and any Java based frameworks, can have their own life cycles and have their own entry points.

== Versus .equals() in Java

Frequently in Java code we come across the usage of == and equals(). The question arises whether == and equals() perform the same operations or whether they work differently. To answer this question, let us examine how == and equals() work and then identify their

4 ways to create an Object in Java

An object is an entity that has state and behavior of a particular entity or places. In addition, it can be a physical or a logical option for stating it. There are three types of characteristics that to be denoted in the Java platform options.

Lambda Expressions in Java

Lambda expression is a significant new feature in Java 8 that enables developers to use functional programming features in Java code. The introduction of lambda expressions and related features in Java 8 has led to the addition of new syntax elements and constructs to the

 


OOPS

What is Aggregation in Java

Aggregation in Java is one of the special case of Association. The directional association present in between the objects can also be determined. When a single object ‘has-a’ another object and you will get the aggregation. The directions between the object will be specified with the object containing other object. Aggregation can also be called as “Has-a” relationship.

What is Association in Java

Association establish relationship between any two objects. It can be defined as the multiplicity between any objects so you must know about the one-to-one, many-to-one, one-to-many and many-to-many as all these are the association between objects.

Difference between Aggregation and Composition

Aggregation is one of the special case of Association. The directional association present in between the objects can also be determined. When a single object ‘has-a’ another object and you will get the aggregation. The directions between the object will be specified with the object

Overriding vs Overloading in Java

Overriding vs overloading is regarded as one of the famous interview questions asked from Java at numerous companies and by plenty of programmers. There are some significant differences taking place between method overriding and overloading in Java

Oops Concepts In Java

Object Oriented Programming is the paradigm or methodology that is used for designing the program using its objects or classes. Generally the object is the real word things like chair, pen, table or any other.

Types Of Inheritance in Java

Inheritance is the key feature for the Object Oriented Programming as there is class to inherit the property allocated. Inheritance in Java occurs when the single class extends with another class then it inherits the non-private members. This includes the fields and methods that is

Types of Polymorphism and advantages

The OOP principles that form the core of Java programming are abstraction, encapsulation, inheritance, and polymorphism. Polymorphism is a significant OOP feature in Java. It enables programmers to create code that is easier to understand and reuse.


 Exception Handling

What is Exception in Java

A statement which is capable of terminating a program abruptly at runtime is known as Exception. In Java they have identified all the possible situations that are capable of terminating a program abruptly and represented them as a hierarchy of classes handled by

Exception handling in Java

In Java when we are not sure about the outcome of a statement, we can try out the statement by placing in a try block. A try block can be used in a method or an another try block. A try block may have any number of catch blocks. But there is no existence of try block with out

Advantages of Exception Handling

Java provides a sophisticated exception handling mechanism that enables you to detect exceptional conditions in your programs and fix the exceptions as and when they occur. Using exception handling features offers several advantages. Let’s examine these advantages in detail.

Top 10 Exceptions in Java

When unwanted, unexpected event that disturbs the normal flow of our program is called Exception. We have discussed about what is exception and how to handling exception in Java in the previous tutorial. Now we are going to discuss about top 10 Exceptions in Java.

How to Handle User Defined Exceptions in Java

User defined exceptions in Java are used to handle the application specific error conditions. Here application specific error conditions are bound to a specific application those are not generic for all the applications.

Try with Resources Example in Java

The try-with-resources statement is an expanded form of the try statement that enables Automatic Resource Management (ARM) in Java. This form of the try statement provides an efficient exception handling mechanism that automatically closes resources after they are used.

Checked and Unchecked Exceptions in Java

There are two types of exceptions in Java, namely, checked exceptions and unchecked exceptions. It is also important to know what is the need of handling the exceptions in our daily development. But at present Let’s examine both these types of exceptions and then identify

Exception Chaining and Debugging in Java with Example

Exception chaining is a Java feature that allows one exception in a program to be associated with another exception. The purpose of using a chained exception is to identify the first exception that caused the second exception. Determining the underlying cause of an exception


Java IO

Java 8 Stream API and Parallelism

When we are creating the array or class instance in the Java application platforms the new object memory is allocated from the single heap. The main reason behind it is that there is a single heap present inside the Java virtual machine as well as the threads shared with it.

How to writing data to a file in Java ?

The most important question when we attend an interview on ios in Java, how to write data in a file using java. Well here is the example, in which we are going to write the data in a file.

How to count number of lines characters and words in a file Java ?

In any Java technical Interview it is a common question asked by the interviewer, how to count number of lines characters and words in a file Java. Here is the example.

How to Search a file in a Directory using Java ?

It a common scenario to search a file in our computer system. it is not only important for Java interview point of view but it is a common requirement to search a file. Here is the example to search a file in a directory.

Serialization and DeSerialization Example in Java

 Serialization is the process of storing the state of an object to a sequence of bytes in the secondary storage device. If we want to make a class as Serializable, we should implement the java.io.Serializable interface, It is a marker interface.


 Collections

How Array works in Java ?

In Java arrays are represented by a class called java.util.Arrays. It is an utility class, to define several utility methods for an array. Both primitive and object type. The class array is considered to be a static factory as this is having all static methods.

Collection Framework in Java

The collection present in Java is the framework for providing the architectures to store and manipulating the groups of objects. All the operations that are performed in the data like searching, sorting, manipulation, deletion, insertion and many others can also be performed by

How Comparable works in Java ?

Comparable in Java is an interface, which was coming from java.lang package. If any class includes Comparable interface then group of that Objects can be arranged automatically using either Arrays.sort() or Collection.sort().

How Comparator works in Java ?

Comparator in Java is an interface, which was coming from java.util package, used to ordering the collection of objects. In order to compare the set of elements in an object , The comparator provides the multiple sorting sequences. Hence we can sort the object based on any property.

How HashMap Works In Java ?

HashMap is one of the classes in the Collections framework. Before examining how HashMap works, let us understand how maps and hash tables work. Maps provide a way to store key/value pairs. In Java, a map is an object that contains key/value associations.

How HashSet works in Java ?

Java Collection Framework provides a set of interfaces and implemented classes. The HashSet is the direct implementation of the Set interface. Which provides the functionality to store the collection of Objects.

TreeSet with Customizable Sorting in Java

In Java Tree set is the implementation of the NavigableSet. The underlying data structure for TreeSet is Balanced Tree. Since it is a Set, it doesn’t allow duplicate values and insertion order is not preserved. But all Objects which are inserted in the tree set is stored according to the some

LinkedHashSet in Java

LinkedHashSet is child class of HashSet, which was introduced at Java 1.4 Version. The underlaying data structure of the LinkedHashSet is the combination of HashTable and LinkedList, hence it is termed as LinkedHashSet.

Vector in Java

Vector in Java is a legacy class that implements a dynamic array. In Java 8, the Vector class is fully compatible with collections framework and implements the List interface. However, the Vector class still retains its old functionality that duplicates some of the methods in the

ArrayList in Java

The ArrayList in Java is a generic class that implements the List interface. This class provides a way to create dynamic arrays in Java. The ArrayList in Java implements all list operations, and permits all operations include duplicates.

Java LinkedList class

The Java LinkedList class is a generic class that provides a linked-list data structure for storing and managing elements. This class implements the List, Queue, and DeQueue interfaces. Some of the key features of the LinkedList class include

Java WeakHashMap class Example

The Java WeakHashMap class implements the Map interface by using a hash table data structure that allows weak keys. A WeakHashMap instance stores weak references to its keys, so that the garbage collector can reclaim memory used by keys that are not in use.

Properties class Example in Java

The Properties class is a subclass of Hashtable. Usually Properties are configuration values managed as key/value pairs. The key identifier is used to retrieve the value like variable name used to retrieve the variable’s value.

 


Thread

Java Thread Life Cycle

The Java thread life cycle is similar to that of the life cycle of processes that runs in an operating system. During the life cycle, the thread shifts from one state to other based on the operation carried out by it or carried out on it.

Thread in Java

Java supports concurrent programming, through its supports for Thread programming. A Thread in Java is a small part of heavy program which is executed individually. It is a sequential path of execution.

Thread join Example in Java

In Java, execution of the program starts from main method. From which all remaining threads are created, these remaining threads are consider to be the child threads of the main thread. The child threads are started after the main thread.

Leave a Reply

Your email address will not be published. Required fields are marked *