Raja has Published 760 Articles

Importance of yield() method in Java?

raja

raja

Updated on 24-Nov-2023 10:37:40

9K+ Views

A yield() method is a static method of Thread class and it can stop the currently executing thread and will give a chance to other waiting threads of the same priority. If in case there are no waiting threads or if all the waiting threads have low priority then the ... Read More

How can we avoid a deadlock in Java?

raja

raja

Updated on 24-Nov-2023 10:33:17

4K+ Views

In Java, a deadlock is a programming situation where two or more threads are blocked forever. A deadlock condition will occur with at least two threads and two or more resources. How To Avoid Deadlock Avoid Nested Locks − A deadlock mainly happens when we give locks to multiple threads. Avoid giving ... Read More

How to find the unicode category for a given character in Java?

raja

raja

Updated on 24-Nov-2023 10:28:35

4K+ Views

A Character class is a subclass of an Object and it wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char. We can determine the unicode category for a particular character by using the getType() method. ... Read More

How to convert an OutputStream to a Writer in Java?

raja

raja

Updated on 24-Nov-2023 09:29:19

1K+ Views

An OutputStream class is a byte-oriented whereas Writer class is a character-oriented. We can convert an OutputStream class to a Writer class using an OutputStreamWriter class and pass an argument of ByteArrayOutputStream object to OutputStreamWriter constructor. An OutputStreamWriter is a bridge from a character stream to a byte stream, the characters ... Read More

Importance of XOR operator in Java?

raja

raja

Updated on 24-Nov-2023 09:25:52

10K+ Views

Bitwise XOR (exclusive or) "^" is an operator in Java that provides the answer '1' if both of the bits in its operands are different, if both of the bits are same then the XOR operator gives the result '0'. XOR is a binary operator that is evaluated from left ... Read More

Will a finally block execute after a return statement in a method in Java?

raja

raja

Updated on 24-Nov-2023 09:21:53

15K+ Views

Yes, the finally block will be executed even after a return statement in a method. The finally block will always execute even an exception occurred or not in Java. If we call the System.exit() method explicitly in the finally block then only it will not be executed. There are few situations ... Read More

How to instantiate a static inner class with reflection in Java?

raja

raja

Updated on 24-Nov-2023 09:18:44

1K+ Views

A static inner class can be instantiated without the need for an instance of the outer class. In general, an Inner class is a part of nested class, called Non-static nested classes in Java. The types of inner classes are member inner class, anonymous inner class, and local inner class. We ... Read More

How can we Implement a Queue using Stack in Java?

raja

raja

Updated on 23-Nov-2023 11:53:18

1K+ Views

A Queue class extends Collection interface and it supports the insert and removes operations using a first-in-first-out (FIFO). A Stack is a subclass of Vector class and it represents last-in-first-out (LIFO) stack of objects. The last element added at the top of the stack (In) can be the first element ... Read More

Importance of return type in Java?

raja

raja

Updated on 23-Nov-2023 11:30:37

22K+ Views

A return statement causes the program control to transfer back to the caller of a method. Every method in Java is declared with a return type and it is mandatory for all java methods. A return type may be a primitive type like i nt, float, double, a reference type ... Read More

How can we implement a custom iterable in Java?

raja

raja

Updated on 23-Nov-2023 11:23:04

1K+ Views

An Iterable interface is defined in java.lang package and introduced with Java 5 version. An object that implements this interface allows it to be the target of the "for-each" statement. This for-each loop is used for iterating over arrays and collections. An Iterable interface can also be implemented to create ... Read More

Previous 1 ... 3 4 5 6 7 ... 76 Next
Advertisements