Found 2617 Articles for Java

Difference between compile-time polymorphism and runtime polymorphism

Himanshu shriv
Updated on 12-Sep-2023 09:54:51

31K+ Views

Polymorphism is one of the most important OOPs concepts. Its is a concept by which we can perform single task in multiple ways. There are two types of polymorphism one is Compile-time polymorphism and another is run-time polymorphism.Method overloading is the example of compile time polymorphism and  method overriding is the example of run-time polymorphism.Sr. No.KeyCompile-time polymorphismRuntime polymorphism1BasicCompile time polymorphism means binding is occuring at compile timeR un time polymorphism where at run time we came to know which method is going to invoke2Static/DynamicBindingIt can be achieved through static bindingIt can be achieved through dynamic binding4.InheritanceInheritance is not involvedInheritance is ... Read More

Difference between mutable and immutable object

Himanshu shriv
Updated on 09-Sep-2020 11:58:34

4K+ Views

In Java, state of the immutable object can’t be modified after it is created b ut definitely reference other objects. They are very useful in multithreading environment because multiple threads can’t change the state of the object so immutable objects are thread safe. Immutable objects are very helpful to avoid temporal coupling and always have failure atomicity.On the other hand, Mutable objects have fields that can be changed, immutable objects have no fields that can be changed after the object is created.Sr. No.KeyMutable objectImmutable object1BasicWe can modify the state of a mutable object after it is createdWe can't modify the ... Read More

Difference between CountDownLatch and CyclicBarrier in Java Concurrency

Himanshu shriv
Updated on 09-Sep-2020 11:55:46

1K+ Views

CountDownLatch and CyclicBarrier both used in multithreading environment and they both are part of.As per Java Doc −CountDownLatch − A synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes.CyclicBarrier − A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point.Sr. No.KeyCyclicBarrierCountDownLatch1BasicA synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point.A synchronization aid that allows one or more threads to wait until a set of operations being ... Read More

Difference between Apache Kafka and JMS.

Himanshu shriv
Updated on 09-Sep-2020 11:47:03

747 Views

Kafka and JMS both are messaging system. Java message service is an api which are provided by Java. It is used for implementing messaging system in your application. JMS supports queue and publisher /subscriber(topic) messaging system . With queues, when first consumer consumes a message, message gets deleted from the queue and others cannot take it anymore. With topics, multiple consumers receive each message but it is much harder to scale.Kafka is a generalization of these two concepts - it allows scaling between members of the same consumer group, but it also allows broadcasting the same message between many different ... Read More

Difference between Point-To-Point and Publish/Subscribe JMS Messaging Models

Himanshu shriv
Updated on 09-Sep-2020 11:44:58

666 Views

JMS is an acronym Java message service. Java message service is an api which are provided by Java. It is used for implementing messaging system in your application.JMS is an API or specification which does not contain implementation therefore to use JMS have to some third party service provider like ActiveMq , Weblogic messaging and etc.JMS support two types of messaging domain −Point to Point MessagingPublish /Subscribe messaging  Sr. No.KeyPoint to Point MessagingPublish /Subscribe1BasicIt is one to one destination of message. Message sent into the queue and that message can be read by only one receiver.It is one to many ... Read More

Difference between default and static interface method in Java 8.

Himanshu shriv
Updated on 31-Oct-2023 03:22:25

24K+ Views

According to Oracle's Javadocs −Default methods enable you to add new functionality to the interfaces of your libraries and ensure binary compatibility with code written for older versions of those interfaces.A static method is a method that is associated with the class in which it is defined rather than with any object. Every instance of the class shares its static methods.Static method in interface are part of the interface class can’t implement or override it whereas class can override the default method.Sr. No.KeyStatic Interface MethodDefault Method1BasicIt is a static method which belongs to the interface only. We can write implementation ... Read More

Difference between PermGen Space and MetaSpace.

Himanshu shriv
Updated on 09-Sep-2020 11:29:52

4K+ Views

PermGen is the memory area for storing class data like static variable, byte code and etc. By default 64 Mb is allocated for PermGen. It can be tuned by using -XXMaxPermSize.In Java 8, PermGen method area replaced with MetaSpace. They have moved permGem to the separate memory in the native OS and that is called MetaSpace. It can by default auto increases its size. In MetaSpace, classes can load and unload during the lifespan of the JVM.Sr. No.KeyPermGenMetaSpace1BasicPermGen is the memory area for storing class data like static variable, byte code and etcIn Java 8, PermGen method area replaced with ... Read More

Difference between Iterator and Spilt Iterator in Java.

Himanshu shriv
Updated on 09-Sep-2020 11:27:40

762 Views

Iterator and split iterator both interface are used for iterating over the collection.Split iterator is introduced in Java 8 for achieving parallelism. It can split the given set of element and can perform operation parallely using different independent threads. It can traverse the elements parallely as well as sequentially manner. There are following important methods in the splitIterator interface −trySplit - It is used for split the given set of elements into multiple pieces.tryAdvance - It is equivalent to the hasNext/ next methods available in Iterator interfacegetExactSizeIfKnown  -It is used to get the size of the given set of elements.Sr. ... Read More

Difference between intermediate and terminal operations in Java 8

Himanshu shriv
Updated on 09-Sep-2020 11:25:15

13K+ Views

Stream is introduced in Java 8, it is only used for processing group of data not for the storting elements.. It does not modify the actual collection, they only provide the result as per the pipelined methods.Stream api supports multiple operations and operations are divided into two parts −Intermediate Operation- These operations are used to pipeline other methods and to transform into the other streams. They don’t produce results because these operation does not invoke until the terminal operation gets executed. Below are the examples −sorted(Comparator)peek(Consumer)distinct()Terminal operations - These operations are used to produce results. They can’t be used for ... Read More

Difference between Function and Predicate in Java 8

Himanshu shriv
Updated on 09-Sep-2020 11:22:33

6K+ Views

Function and Predicate both functional interface was introduced in Java 8 to implement functional programming in Java.Function interface is used to do the transformation.It can accepts one argument and produces a result. On the other side, Predicate can also accept only one argument but it can only return boolean value. It is used to test the condition.Sr. No.KeyFunctionPredicate1BasicIt can take 2 type parameters First one represents input type argument type and second one represents return type.It can take one type parameter which represents input type or argument type.2Return TypeIt can return any type of value.It can only return boolean value3MethodIt ... Read More

Advertisements