
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2574 of 3366

4K+ Views
To check if a variable is an array in Javascript is essential to handle data appropriately. We will discuss three different approaches to check if a variable is an array or not. We are having an array and a string, and our task is to check if a variable is an array in JavaScript. Approaches to Check if a Variable is an Array Here is a list of approaches to check if a variable is an array in JavaScript which we will be discussing in this article with stepwise explaination and complete example codes. Using ... Read More

6K+ Views
Yes, constructors are allowed to throw an exception in Java.A Constructor is a special type of a method that is used to initialize the object and it is used to create an object of a class using the new keyword, where an object is also known as an Instance of a class. Each object of a class will have its own state (Instance variables) and access to methods of its class.Throw an Exception from a ConstructorA checked exception can be used to indicate a legitimate problem when trying to create an instance, while an unchecked exception typically indicates a bug either in the ... Read More

6K+ Views
A static block is a set of statements, which will be executed by the JVM before the execution of the main() method. At the time of class loading if we want to perform any activity we have to define that activity inside a static block because this block executes at the time of class loading.Throw an exception from a Static BlockA static block can throw only a RunTimeException, or there should be a try and catch block to catch a checked exception.A static block occurs when a class is loaded by a class loader. The code can either come in the form ... Read More

336 Views
There are a couple of ways to find whether a key exist in javascript object or not.Let's say we have an 'employee' object as shown below. var employee = { name: "Ranjan", age: 25 }Now we need to check whether 'name' property exist in employee object or not.1) 'In' operatorWe can use 'in' operator on object to check its properties. The 'in' operator also looks about inherited property if it does not find any actual properties of the object.In the following example when 'toString' is checked whether present or not, the 'in' operator ... Read More

852 Views
There are a couple of ways to empty an array in javascript.Let's suppose take an arrayvar array1 = [1, 2, 3, 4, 5, 6, 7];Method 1var array1 = [];The code above will set the number array to a new empty array. This is recommended when you don't have any references to the original array 'array1'. You should be careful with this way of empty the array, because if you have referenced this array from another variable, then the original reference array will remain unchanged.Example var array1 = [1, 2, 3, 4, 5, 6, 7]; // ... Read More

2K+ Views
A class that is declared inside a class but outside a method is known as member inner class.We can instantiate a member Inner class in two waysInvoked within the classInvoked outside the classRules for Inner ClassThe outer class (the class containing the inner class) can instantiate as many numbers of inner class objects as it wishes, inside its code.If the inner class is public & the containing class as well, then code in some other unrelated class can as well create an instance of the inner class.No inner class objects are automatically instantiated with an outer class object.If the inner ... Read More

5K+ Views
In Java, both ClassNotFoundException and NoClassDefFoundError are issues that occur when the JVM or ClassLoader is not able to find the appropriate class at the time of loading (run-time). The ClassNotFoundException is a checked exception, and NoClassDefFoundError is an Error that comes under unchecked. There are different types of ClassLoaders, each responsible for loading classes from different sources such as directories, JAR files, or network locations. If a required class is missing due to an incorrect classpath or a missing JAR file, the ClassLoader might fail to load it. This situation leads to one of these two issues. The ClassNotFoundException in ... Read More

12K+ Views
To begin with, Polymorphism is gotten from the Greek words Poly (which means many) and morphism (which meaning forms).Polymorphism portrays an example in object-oriented programming where methods in various classes that do similar things should have a similar name. Polymorphism is essentially an OOP pattern that enables numerous classes with different functionalities to execute or share a commonInterface. The usefulness of polymorphism is code written in different classes doesn't have any effect which class it belongs because they are used in the same way. In order to ensure that the classes do implement the polymorphism guideline, we can pick between ... Read More

39K+ Views
A PHP application produces many levels of errors during the runtime of the script . So in this article, we will learn how to display all the errors and warning messages. The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); The ini_set function will try to override the configuration found in your php.ini file. If in the php.ini file display_error is turned off it will turn that on in the code. It also set display_startup_errors to true to show the error message. error_reporting() ... Read More

2K+ Views
Pass by value In pass by value, a function is called by directly passing the value of the variable as the argument. Changing the argument inside the function doesn’t affect the variable passed from outside the function. Javascript always pass by value so changing the value of the variable never changes the underlying primitive (String or number).In the following example, variable 'a' has assigned value 1. But inside function 'change' it got assigned with value 2. Since javascript is always a pass by value, the displayed output will be '1' but not '2'.ExampleLive Demo let a = 1; ... Read More