TCS Java Interview Questions

In this post, we covered the TCS java interview questions. The candidate got asked about the Java 8 Stream operations where he was given two list and he has to do concatenation of two lists. After that he has to find the unique elements from the list and finally he Read more…

How Generics Work in Java?

Let’s examine how generics work in Java. Also, we will look at how generics is a compile-time feature. To demonstrate this concept, we are going to mix generic and non-generic types. But in the real world never mix these two types. Let’s try to mix the generic and non-generic types Read more…

Autoboxing with Generics in Java

In this post, we are going to look at how autoboxing works with Generics in Java. Autoboxing is a feature that got introduced in Java 1.5 and it plays a very important role while using generics. As we know generic collections can only hold object types. But Java also has Read more…

Why Generics in Java?

Generics got introduced in Java SE 5.0, but the question is why use generics in the first place? In this tutorial, we are going to look at some of the problems that developers faced before generics. Before generics, it is the developer’s responsibility to add the correct types of elements Read more…

Python program to find out the number of CPUs

Use the multiprocessing module of python to find the number of CPUs. cpu_count() is the function that returns the count of CPUs. Algorithm Start Import multiprocessing module Use the cpu_count() function provided in the multiprocessing module, it will return the number of CPU Display the count End Program Output CPUs Read more…

HashMap clear() Method in Java

The clear() method of HashMap removes all the mappings from the map. After a call to the clear method, the HashMap becomes empty and the size of a map effectively becomes zero. There is no way to get back the elements once the clear operation is complete. This method is Read more…

HashMap keySet() Method in Java

The keySet() method of HashMap returns a set of keys contained in it. Any changes to the map also modify the returned set and vice versa. Removing value from the set also removes the associated key/value pair from the Hashmap. There is no provision to do add operations on the Read more…