Blockchain has become a buzz word in the recent times. It is being tried to be implemented in every software for various purposes, to check how it would work efficiently given different scenarios. It is a decentralized technology. It basically is data that is digital in nature and every piece of data is known as a transaction. Hence, the date, time and amount of that specific transaction is stored in the blockchain. Every block is unique due to the unique code it has, that is also known as ‘hash’. It is created with the help of different specialized algorithms.Investors are ... Read More
Once the byte code is loaded by the JVM, (with the help of the .class file), the bytecode is checked to see the validity with the help of the verifier. The verifier checks the linking so as to perform operations efficiently. This way, the interpreter performs much efficiently. This process is known as verification.Example Live Demopublic class Demo{ private float my_val; float my_function(int my_val){ int balance = my_val; this.my_val += balance; return this.my_val; } public static void main(String[] args){ Demo my_obj = new Demo(); ... Read More
Given the task is to find the maximum number without any leading or trailing zeroes or ones whose product of factorial of its digits is equal to the product of factorial of digits of the given number N.Let’s now understand what we have to do using an example −Input − N = 4912Output − 73332222Explanation − 4! * 9! * 1! * 2! = 7! * 3! * 3! * 3! * 2! * 2! *2! *2! = 17, 418, 240Input − N = 340Output − 3322Approach used in the below program as followsIn order to attain the maximum answer ... Read More
Given the task is to find the maximum number that can be displayed using N segment on ant number of seven segment display.Let’s now understand what we have to do using an example −Input − N=5Output − 71Explanation − The largest number will be displayed as follows on the seven segment display −Input − N=6Output − 111Approach used in the below program as followsThe following situation can be divided into 3 case −Case 1 −If N is 0 or 1, then it is not possible to display any number.Case 2 −If N is odd. Then the numbers that can be ... Read More
Given the task is to find the maximum number of Zombie processes that a system can handle or in other words, the program does not stop its execution.A Zombie process (also known as defunct process) is a process that has completed its process via exit() (system call) but still has an entry in the process table.Approach used in the below program as followsNote that should be added in order to run the program.In main() function initialize num = 0 of type int which we will iterate until the program stops being executed.To initiate a zombie process create a while statement ... Read More
There are many features that can be seen in C++ but not in Java. A few of them have been listed below −No unsigned int option in JavaNo destructor in Java as well as ‘delete’ since garbage collector performs this operation for it.No friend classes or friend functions in Java.There are no pointers in Java.There is no typedef option in Java.Since Java is a purely object oriented language, there are no global variables or global functions.The concept of templates present in C++ can’t be found in Java.The ‘::’ scope resolution operator is not there, since there is no question of ... Read More
Given the task is to find the maximum number of unique prime factors a number can have in the range of [1, N] where N is given.Let’s now understand what we have to do using an example −Input − N=100Output − 3Explanation − Let us take 30 in the range of [1, 100]30 = 3 * 2 * 5 = unique prime factors. Therefore, in the range of [1, 100] a maximum of 3 unique factors can be found.Input − N=300Output − 4Approach used in the below program as followsIn function MaxPrime() we will first check if (N < 2). ... Read More
Given the task is to find the maximum number of trailing zeroes in the product of the subsets of size K, of a given array of size N.Let’s now understand what we have to do using an example −Input − Arr[] = {5, 20, 2} , K=2Output − 2Explanation − A total of 3 subsets can be created having size = 2.The product of [5, 20] is 100.The product of [20, 2] is 40.The product of [5, 2] is 10.100 has the maximum number of trailing zeros = 2. Therefore 2 is the answer.Input − Arr[] = {60, 40, 25} ... Read More
Soft references are often used to implement memory-sensitive caches. Let us see an example of soft references in Java −Example Live Demoimport java.lang.ref.SoftReference; class Demo{ public void display_msg(){ System.out.println("Hello there"); } } public class Demo_example{ public static void main(String[] args){ Demo my_instance = new Demo(); my_instance.display_msg(); SoftReference my_softref = new SoftReference(my_instance); my_instance = null; my_instance = my_softref.get(); my_instance.display_msg(); } }OutputHello there Hello thereA class named Demo contains a function named ‘display_msg’, that displays the relevant ... Read More
In this problem, we are given a number n which defines the n-th term of the series 2^0, 2^1, 2^2, …, 2^n. Our task is to create a program to find the sum of the series 2^0 + 2^1 + 2^2 +...+ 2^n.Let’s take an example to understand the problem, Inputn=6Output Explanation sum = 2^0 + 2^1 + 2^2 + 2^3 + 2^4 + 2^5 + 2^6 sum = 1 + 2 + 4 + 8 + 16 + 32 + 64 = 127A simple solution to the problem is by using the loop. Finding the 2^i, for each value from 0 ... Read More