Difference Between extends and implements Keywords in Java

AmitDiwan
Updated on 24-Mar-2021 12:42:58

2K+ Views

In this post, we will understand the differences between ‘Extends’ and ‘Implements’ keyword.ExtendsUsing this, a class can be used as a base class, and another class inherits this base class.An interface can also inherit other interfaces using this keyword.Only one superclass can be extended by a class.Any number of interfaces can be extended by an interface.It is not required for the subclass (that extends a superclass) to override all the methods in the superclass.Following is an example of the extends keyword −Exampleclass Super { ..... ..... } class Sub extends Super { ... Read More

Difference Between HashMap and LinkedHashMap in Java

AmitDiwan
Updated on 24-Mar-2021 12:38:17

1K+ Views

In this post, we will understand the difference between HashMap and LinkedHashMap in Java.HashMapIn this structure, the order of insertion is not preserved.It uses the HashTable to store maps.It extends the ‘AbstractMap’.It implements the ‘Map’ interface.This was introduced in JDK 2.0.It has a relatively low overhead.LinkedHashMapIn this structure, the order of insertion is not preserved.It uses the HashTable and Linked List to store maps.It extends the ‘Hashmap’.It implements the ‘Map’ interface.This was introduced in JDK 4.0.It has a relatively higher overhead.This is because it has to maintain the order of entries in the map structure.Read More

Add Two Complex Numbers by Passing Structure to a Function in C

Bhanu Priya
Updated on 24-Mar-2021 12:36:51

7K+ Views

In order to add two complex numbers in C programming language, the user has to take two complex numbers as structure members and perform addition operation on those two numbers by creating a user-defined function.AlgorithmRefer an algorithm given below for addition of two complex numbers.Step 1: Declare struct complex with data members. Step 2: Declare name for structure and variables. Step 3: Enter real and imaginary part for first complex number at run time. Step 4: Enter real and imaginary part for second complex number at runtime Step 5: Compute addition of number1 and number2 by calling function. Go to ... Read More

Difference Between Iterator and Enumeration Interface in Java

AmitDiwan
Updated on 24-Mar-2021 12:34:07

565 Views

In this post, we will understand the difference between iterator and enumeration interfaces in Java.IteratorIt is a universal cursor.It can be applied to all collection of classes.It contains the ‘remove’ method.It is not a legacy interface.It can be used to traverse over HashMap, LinkedList, ArrayList, HashSet, TreeMap, and TreeSet .It can perform modifications to perform operations on the collection while traversing through it.EnumerationIt is not a universal cursor.It is applied only to legacy classes.It doesn’t contain the ‘remove’ method.It is a legacy interface.This interface acts like a read-only interface.Hence, no modifications can be performed on a collection while traversing over ... Read More

Difference Between malloc and calloc

AmitDiwan
Updated on 24-Mar-2021 12:31:57

899 Views

In this post, we will understand the difference between malloc and calloc.MallocThe method ‘malloc’ is used to assign a block of memory when it is requested.It doesn’t clear the memory.It only initializes the allocated memory when explicitly requested.It allocates memory of a specific ‘size’.This size is passed as parameter to it.This size is allocated from a heap.It performs its job quickly.Examplevoid *malloc(size_t size);CallocIt assigns the requested memory to multiple blocks.This memory allocated is initiated to zero.This initialization to 0 is done by ‘calloc’ method.It allocates memory to the required operation of a specific ‘size’, i.e num * size.The ‘num’ refers ... Read More

Difference Between Stack and Queue

AmitDiwan
Updated on 24-Mar-2021 12:28:30

921 Views

In this post, we will understand the difference between Stack and Queue.StackThey are based on LIFO- Last In First Out.This means the element inserted at the end is the first element to get deleted.Insertion and deletion happen in a stack from one end only, i.e the top.Insert operation is known as ‘push’ operation.Delete operation is known as ‘pop’ operation.A pointer is used to access the list, it is known as ‘top’.The ‘top’ points to the last element of the list.It helps work with problems associated with recursion.Representation of Stack (LIFO)QueuesThey are based on FIFO- First In First Out.This means the ... Read More

RTOS Introduction with Arduino

Yash Sanghvi
Updated on 24-Mar-2021 05:46:29

1K+ Views

RTOS stands for Real Time Operating System. It is used to run multiple tasks concurrently, schedule them as required, and enable them to share resources. Now, while getting into the details of RTOS is out of the scope of this article, we will walk through an example that will give you a fair idea of RTOS. For now, you can just note that RTOS will help you perform multi-tasking within your Arduino, just like how the OS on your machine helps you run multiple tasks (like writing mails, listening to music, etc.) simultaneously.Now, since we are concerned with microcontrollers, we ... Read More

Timer Interrupts in Arduino

Yash Sanghvi
Updated on 24-Mar-2021 05:41:38

4K+ Views

As discussed in another article, Timers are basically counters. When they reach the end of the count, they overflow. We can use this event to generate an interrupt. Now, the traditional way of generating the interrupts in Arduino involve changing a lot of registers. Luckily, we have libraries for making our lives easy.We will use the TimerOne library for generating interrupts on Timer1. Similarly, there is the TimerThree library for generating interrupts on Timer3 (not applicable for Arduino Uno).Go to Tools -> Manage Libraries and search for TimerOne and TimerThree (optional) and click Install.Next, import the library in your code ... Read More

Timers in Arduino Uno

Yash Sanghvi
Updated on 24-Mar-2021 05:39:15

10K+ Views

As discussed earlier, Arduino Uno has 3 timers: Timer0, Timer1 and Timer2. Timer0 and Timer2 are 8-bit counters (they count from 0 to 255), while Timer1 is a 16-bit counter (it counts from 0 to 65535). Internally, Timer0 is used for the millis() function, and therefore, it is recommended not to mess with it. You can use Timer1 and Timer2 for your custom requirements.Note that the clock frequency of Arduino Uno is 16 MHz. Therefore, no timer can have intervals shorter than (1/16000000). However, for most applications, you would want longer intervals (lower frequencies). In other words, you would want ... Read More

Timers in Arduino

Yash Sanghvi
Updated on 24-Mar-2021 05:38:49

2K+ Views

Every microcontroller has one or more timers that help the users perform tasks at precise intervals. Arduino Uno, for example, has 3 timers: Timer0, Timer1 and Timer2. Other boards may have the same or different number of timers, which you can find from the datasheet of that board/ microcontroller. What are timers?Timers are essentially counters. Let me give you a simple example. Say you want to trigger a task every 5 seconds. Now, if you have a counter which can count from 0 to 255, then if you somehow adjust the rate of counting such that it finishes counting exactly in ... Read More

Advertisements