
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
Found 9150 Articles for Object Oriented Programming

3K+ Views
The terms "parameters" and "arguments of a function" are frequently used synonymously in JavaScript, despite the fact that there is a substantial distinction between the two. The function parameters are included when we define a function. While defining a function, you may also specify a list of variables; these variables are referred to as function parameters. On the other hand, "function parameters" are the values we pass when we call or execute the newly created function. In JavaScript, the variables listed in the function declaration serve as the argument values. The arguments that are part of the function definition are ... Read More

491 Views
The unshift method adds the element at the zeroeth index and shifts the values at consecutive indexes up, then returns the length of the array.The push() method adds the element at end to an array and returns that element. This method changes the length of the array.Examplelet fruits = ['apple', 'mango', 'orange', 'kiwi']; let fruits2 = ['apple', 'mango', 'orange', 'kiwi']; console.log(fruits.push("pinapple")) console.log(fruits2.unshift("pinapple")) console.log(fruits) console.log(fruits2)Output5 5 [ 'apple', 'mango', 'orange', 'kiwi', 'pinapple' ] [ 'pinapple', 'apple', 'mango', 'orange', 'kiwi' ]Note that both the original arrays were changed here.Unshift is slower than push because it also needs to unshift all the elements ... Read More

513 Views
The shift method removes the element at the zeroeth index and shifts the values at consecutive indexes down, then returns the removed value. If the length property is 0, undefined is returned.The pop() method removes the last element from an array and returns that element. This method changes the length of the array.Examplelet fruits = ['apple', 'mango', 'orange', 'kiwi']; let fruits2 = ['apple', 'mango', 'orange', 'kiwi']; console.log(fruits.pop()) console.log(fruits2.shift()) console.log(fruits) console.log(fruits2)Outputkiwi apple [ 'apple', 'mango', 'orange' ] [ 'mango', 'orange', 'kiwi' ] Note that both the original arrays were changed here.Shift is slower than pop because it also needs to shift all ... Read More

424 Views
The basic difference between slice and splice is −splice() changes the original array on which it is called and returns the removed item(s) in an array as a new array object.slice() doesn't change the original array and also returns the array sliced.Example// splice changes the array let arr = [1, 2, 3, 4, 5]; console.log(array.splice(2)); //slice doesn't change original one let arr2 = [1, 2, 3, 4, 5]; console.log(array2.slice(2)); console.log(" After Changing the arrays"); console.log(array); console.log(array2);Output[ 3, 4, 5 ] [ 3, 4, 5 ]After Changing the arrays[[ 1, 2 ] [ 1, 2, 3, 4, 5 ]

251 Views
Shallow copy and deep copy are language agnostic. Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements.Examplelet innerObj = { a: 'b', c: 'd' } let obj = { x: "test", y: innerObj } // Create a shallow copy. let copyObj = Object.assign({}, obj); // Both copyObj and obj's prop y now refers to the same innerObj. Any changes to this will be reflected. innerObj.a = "test" console.log(obj) console.log(copyObj)Output{ x: 'test', ... Read More

264 Views
The radix sort algorithm distributes integers into buckets based on a number's significant digit or value (the radix). The radix is based on the number system of the values of the arrays. Let us look at how it can be implemented −Examplefunction radixSort(arr) { // Find the max number and multiply it by 10 to get a number // with no. of digits of max + 1 const maxNum = Math.max(...arr) * 10; let divisor = 10; while (divisor < maxNum) { // Create bucket arrays for each of 0-9 ... Read More

530 Views
JavaScript provides us with functions, that are a collection of pre-defined instructions or statements that are only carried out when we call the function that contains this code. The function accepts one or more arguments as input and output. You can pass values or references for the input arguments. All function parameters are always given by value in JavaScript. It indicates that JavaScript inserts copies of variable values into function parameters. The passing variables outside of the function are not affected by any modifications you make to the function's internal arguments. Or, to put it another way, changes made to ... Read More

2K+ Views
A static block is a block of code with a static keyword. In general, these are used to initialize the static members. JVM executes static blocks before the main method at the time of class loading.Example Live Demopublic class MyClass { static{ System.out.println("Hello this is a static block"); } public static void main(String args[]){ System.out.println("This is main method"); } }OutputHello this is a static block This is main methodExceptions in static blockJust like any other method in Java when an exception occurs in static block you can handle it using try-catch ... Read More

9K+ Views
Whenever an exception occurred in a loop the control gets out of the loop, by handling the exception the statements after the catch block in the method will get executed. But, the loop breaks.Example Live Demopublic class ExceptionInLoop{ public static void sampleMethod(){ String str[] = {"Mango", "Apple", "Banana", "Grapes", "Oranges"}; try { for(int i=0; i

1K+ Views
DescriptionWhen a piece of code in particular method throws an exception, and is handled using try-catch pair. If we are calling this method from another one and, the calling line is wrapped within try-catch pair. Now, how can I override the catch block by the catch block of the calling method.When a piece of code in a method throws an exception (compile time) we must either handle it by wrapping it within the try-catch pair or, throw it (postpone) to the calling method using the throws keyword else a compile time error occurs.In the following Java example the code in ... Read More