Difference Between Compile-Time and Runtime Polymorphism

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

36K+ 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

What are Virtual Machines in Operating System

Bhanu Priya
Updated on 12-Sep-2023 09:53:20

36K+ Views

A virtual machine (VM) is a virtual environment which functions as a virtual computer system with its own CPU, memory, network interface, and storage, created on a physical hardware system.VMs are isolated from the rest of the system, and multiple VMs can exist on a single piece of hardware, like a server. That means, it as a simulated image of application software and operating system which is executed on a host computer or a server.It has its own operating system and software that will facilitate the resources to virtual computers.Characteristics of virtual machinesThe characteristics of the virtual machines are as ... Read More

Generate a Random Array of Integers in Java

Anvi Jain
Updated on 12-Sep-2023 03:29:56

39K+ Views

In order to generate random array of integers in Java, we use the nextInt() method of the java.util.Random class. This returns the next random integer value from this random number generator sequence.Declaration − The java.util.Random.nextInt() method is declared as follows −public int nextInt()Let us see a program to generate a random array of integers in Java −Example Live Demoimport java.util.Random; public class Example {    public static void main(String[] args) {       Random rd = new Random(); // creating Random object       int[] arr = new int[5];       for (int i = 0; i

Convert JSON Object to Array in JavaScript

Nikhilesh Aleti
Updated on 12-Sep-2023 03:27:16

42K+ Views

The JSON (JavaScript object notation) Object can be created with JavaScript. JSON Object is always surrounded inside the curly brackets {}. The keys must be in strings and values must be in valid JSON data type. The data types like string, number, object, Boolean, array, and Null will be supported by JSON. The keys and values are separated by a colon(":") and a comma separates each key and value pair. Syntax Following is the syntax of JSON Object − var JSONObj = {}; The below example is the basic declaration of a JSON object in JavaScript − var JSONObj ... Read More

Delete Duplicate Elements in an Array in C

Bhanu Priya
Updated on 12-Sep-2023 03:23:56

53K+ Views

Try to delete the same numbers present in an array. The resultant array consists of unique elements.The logic to delete the duplicate elements in an array is as follows −for(i=0;i

Get List of All Files and Folders from a Folder in Java

Maruthi Krishna
Updated on 12-Sep-2023 03:22:52

43K+ Views

The class named File of the java.io package represents a file or directory (path names) in the system. This class provides various methods to perform various operations on files/directories.To get the list of all the existing files in a directory this class provides the files class provides list() (returns names) and ListFiles() (returns File objects) with different variants.The List() methodThis method returns a String array which contains the names of all the files and directories in the path represented by the current (File) object.Using this method, you can just print the names of the files and directories.ExampleThe following Java program ... Read More

Save Plots into a PDF in Matplotlib

Rishikesh Kumar Rishi
Updated on 12-Sep-2023 03:11:35

69K+ Views

Using plt.savefig("myImagePDF.pdf", format="pdf", bbox_inches="tight") method, we can save a figure in PDF format.StepsCreate a dictionary with Column 1 and Column 2 as the keys and Values are like i and i*i, where i is from 0 to 10, respectively.Create a data frame using pd.DataFrame(d), d created in step 1.Plot the data frame with ‘o’ and ‘rx’ style.To save the file in PDF format, use savefig() method where the image name is myImagePDF.pdf, format = ”pdf”.To show the image, use the plt.show() method.Exampleimport pandas as pd from matplotlib import pyplot as plt d = {'Column 1': [i for i in ... Read More

Convert NumPy ndarray to PyTorch Tensor and Vice Versa

Shahid Akhtar Khan
Updated on 12-Sep-2023 03:08:40

34K+ Views

A PyTorch tensor is like numpy.ndarray. The difference between these two is that a tensor utilizes the GPUs to accelerate numeric computation. We convert a numpy.ndarray to a PyTorch tensor using the function torch.from_numpy(). And a tensor is converted to numpy.ndarray using the .numpy() method.StepsImport the required libraries. Here, the required libraries are torch and numpy.Create a numpy.ndarray or a PyTorch tensor.Convert the numpy.ndarray to a PyTorch tensor using torch.from_numpy() function or convert the PyTorch tensor to numpy.ndarray using the .numpy() method.Finally, print the converted tensor or numpy.ndarray.Example 1The following Python program converts a numpy.ndarray to a PyTorch tensor.# import ... Read More

Encrypt and Decrypt Data in Node.js

Mayank Agarwal
Updated on 12-Sep-2023 03:06:57

49K+ Views

NodeJS provides inbuilt library crypto to encrypt and decrypt data in NodeJS. We can use this library to encrypt data of any type. You can do the cryptographic operations on a string, buffer, and even a stream of data. The crypto also holds multiple crypto algorithms for encryption. Please check the official resources for the same. In this article, we will use the most popular AES (Advanced Encryption Standard) for encryption.Configuring 'crypto' dependencyIn your project, check if NodeJS is initialized or not. If not, use the following command to initialize NodeJS.>> npm init -yThe 'crypto' library is automatically added while ... Read More

Display Selected Option in Dropdown List with JavaScript

Shubham Vora
Updated on 12-Sep-2023 03:02:04

33K+ Views

In this tutorial, we will learn how to display the selected option in a dropdown list with JavaScript. What is a dropdown list? A dropdown list is a switchable menu that enables users to select one item from various options. A drop-down list is generated with the tag is most frequently used in forms to gather user input. After submitting the form, the name attribute must refer to the form's data. The DOM API functions getElementById() and querySelector() can be used to choose a element. The process use the querySelector() function to first select the "button" and "select" ... Read More

Advertisements