Thread Synchronization in Java

When two or more threads try to access the same resource, they need somehow to ensure that the resource will be used by only one thread at a time. The process by which this achive is called Synchronization. Java uses the concept of monitor (also called semaphore) for Synchronization. The monitor allows one thread at … Read more

Thread Priorities in Java

In java, when two or more than  two thread is computing for CPU time, every thread is assigned a priority value. A highest Priority thread get preference over lower priority thread.   All Java threads have a priority in the range 1-10. Top priority is 10, lowest priority is 1.Normal priority ie. priority by default … Read more

Main Thread in Java

In Java programming, when a program begins the first thread that starts running is called main thread.  Other threads(child thread) can be spawned from this main thread. When program terminates, the main thread must be the last thread in the program to end. When the main thread stops, the program stops running. Main thread is … Read more

Finally Keyword in Java

In java exception handling, any code that we want to must be execute put inside the finally block. After the execution of try and catch block, finally block executes. try block must be used with either catch or finally, or with both. Normally when exception occurs then further programs never executes.  But either exception occurs … Read more

Java Interfaces

In Java programming, an interface is a collection of method declaration and constant that one or more class can use. It is syntactically similar to the class but the main difference between class and interface is that class contain method declaration with method body and interface method declares without any body. Syntax of interface:

Read more

Java final keyword

Final is using for three purpose: final is used to prevent method overriding final is used to prevent inherit a class final is used to make a variable constant final is used to prevent overriding: A method declared as final can’t be overridden.

Because show() declared as final, it can’t be overridden in B. If  … Read more

Java Abstract class

Any class that contains one or more abstract method must also be declared abstract. We can declare an abstract class by using the abstract keyword in front of class keyword at the beginning of the class declaration. An abstract method is a method which declares in super class and defines by the associate subclass. To … Read more

Method Overriding in Java

Method overriding is one of the importance concept in Java Programming. What is Method Overriding? In Inheritance hierarchy when a child class defines exact same method that is available in parent class then the method is called overridden method. The process of creating overridden method is called method overriding.

Result

We have created … Read more

Java Nested and Inner Class

In java programming it is possible to define a class within another class, such classes are known as nested class. There are two types of nested classes:-                                                                                                                                1. Non-static inner class                                                  … Read more

JavaAccess Control (Access modifier)

There are there types of access modifiers in Java. They are: public private and protected. public:  A public data can be accessed by outside of the code in which it is defined. private: A private data can not be accessed by outside of the code in which it is defined. The private data can be … Read more