Write a program to sort employees by their experience. Employee class is not allowed to implement any interface.

Answer: For sorting employees we need to use either Comparable or comparator interface. Since, as per question, the Employee class is not allowed to implement any Interface, only option is, to create a new comparator class that implements Comparator interface. And in “compare()” method Read more →

Can you delete this pointer inside a class member function in C++?

Answer: Yes, we can delete “this” pointer inside a member function only if the function call is made by the class object that has been created dynamically i.e. using “new” keyword. As, delete can only be applied on the object that has been created Read more →

Can we overload a generic method in C#?

Answer: Yes, we can overload a generic methods in C# as we overload a normal method in a class. Example: using System; using System.Collections.Generic; using System.Linq; using System.Text; class GenericMethodOverloading { //Overloaded generic method with one parameter public void CustomPrint(T value) { Console.WriteLine(“In overloaded Read more →

What is difference between Arraylist and Vector in java?

Difference between Arraylist and Vector in java in Java Collections. We will be listing four important difference between java arraylist and vector data structures. Note that two differences that thread safety and performance difference should be given extra focus. Java ArrayList Vs Vector ArrayList Read more →

ADT(Abstract Data Type) Vs Data Structure Interview question

Answer: ADT (Abstract Data type) represents a set of particular behaviors. for example, LIST represents a sequence of values, a QUEUE represents a FIFO(First in First Out) logic on additions/deletions operations etc. ADTs are abstracted from the implementation detail of operations. For example, Add() Read more →

What is time complexity for offer, poll and peek methods in priority queue Java ?

Answer: Time complexity for the methods offer & poll is O(log(n)) and for the peek() it is Constant time O(1) of java priority queue.   NOTES: In Java programming, Java Priority Queue is implemented using Heap Data Structures and Heap has O(log(n)) time complexity Read more →