
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

415 Views
Inheritance is concept where one class accesses the methods and properties of another class.Parent class is the class being inherited from, also called base class.Child class is the class that inherits from another class, also called derived class.There are two types of inheritance in python −Multiple InheritanceMultilevel InheritanceMultiple Inheritance −In multiple inheritance one child class can inherit multiple parent classes.Exampleclass Father: fathername = "" def father(self): print(self.fathername) class Mother: mothername = "" def mother(self): print(self.mothername) class Daughter(Father, Mother): def parent(self): print("Father :", self.fathername) ... Read More

4K+ Views
We will face two cases while calling the parent constructor method in child class.Case1We can't run directly the parent class constructor in child class if the child class defines a constructor. In order to run a parent constructor, a call to parent::__construct() within the child constructor is required.Example Live DemoOutput: I am in Tutorials Point I am not in Tutorials PointExplanationIn the above example, we have used parent::__construct() to call the parent class constructor.Case2If the child does not define a constructor then it may be inherited from the parent class just like a normal class method(if it was not declared as ... Read More

193 Views
Object.is()Object.is() is used to check whether two values are same or not. Two values are same when they have the following criteria. Either both the values are undefined or null .Either both are true or false.Both strings should be of same length, same characters and in same order.The polarities of both the values should be equal.Both the values can be NaN and should be equal.syntaxObject.is(val1, val2);It accepts two parameters and scrutinize whether they are equal or not. If equal gives out true as output else false as output.There is a small difference between Object.is() and "==" that is when comparing +0 and -0, the former results false whereas the latter results true. ... Read More

2K+ Views
The NumberFormatException is a class that represents an unchecked exception thrown by parseXXX() methods when they are unable to format (convert) a string into a number. Here, the parseXXX() is a group of Java built-in methods that are used to convert string representations of numbers into their corresponding primitive data types. Causes for NumberFormatException in Java The NumberFormatException extends IllegalArgumentException class of java.lang package. It can be thrown by many methods/constructors of the classes. Following are some of them: int parseInt(String s): It throws NumberFormatException if ... Read More

7K+ Views
Java ArithmeticException The ArithmeticException of java.lang package is an unchecked exception in Java. It is raised when an attempt is made to use a wrong mathematical expression in the Java program. An example of ArithmeticExeption is division by 0. If you divide two numbers and the number in the denominator is zero. The Java Virtual Machine will throw ArithmeticException. Example: Throwing ArithmeticException In the following Java program, we try a mathematical operation where we divide a number by 0. public class ArithmeticExceptionTest { public static void main(String[] args) { int a ... Read More

5K+ Views
To add two strings we need a '+' operator to create some space between the strings, but when the first string itself has a space with in it, there is no need to assign space explicitly. In the following example since the string 'str1' has a space with in it, just only concatenation without space is adequate to add both the strings.ExampleLive Demo function str(str1, str2) { return (str1 + str2); } document.write(str("tutorix is the best ", "e-learning platform")); Outputtutorix is the best ... Read More

11K+ Views
The protected and default access modifiers determine how a member of a class or method can be accessed. The modifiers are attached to the members at the time of declaration. Since Java follows the object-oriented programming paradigm, these access modifiers are used in encapsulation, polymorphism, and inheritance to control the behavior of class members. We will try to understand the difference between protected and default access modifiers in Java through this article. Protected Access Modifier The protected access modifier is mostly used in the case of inheritance to control the access of parent class members and corresponding child class members. ... Read More

384 Views
Parsing an URLIt is very simple to parse an URL in javascript by using DOM method rather than Regular expressions. If regular expressions are used then code will be much more complicated. In DOM method just a function call will return the parsed URL. In the following example, initially a function is created and then an anchor tag "a" is created inside it using a DOM method. Later on the provided URL was assigned to the anchor tag using href. Now, when function returns the parts of the URL, it tries to return the parsed parts as shown in the output. ... Read More

2K+ Views
The OutOfMemoryError is thrown by JVM, when JVM does not have enough available memory, to allocate. OutOfMemoryError falls into the Error category in Exception class hierarchy.To generate OutOfMemoryErrorWe will allocate a large chunk of memory, which will exhaust heap memory storage.We will keep on allocating the memory and point will reach, when JVM will not have enough memory to allocate, then OutOfMemoryError will be thrown.Once we will catch the OutOfMemory error, we can log the error.ExampleLive Demopublic class OutOfMemoryErrorDemo { public static void main(String[] args) throws Exception { int dummyArraySize = 15; System.out.println("Max JVM memory: " + Runtime.getRuntime().maxMemory()); ... Read More

2K+ Views
No, we can not place any code after throw statement, it leads to compile time error. The compiler will show this error as unreachable statement. In Java, the throw statement immediately terminates the current flow of execution, therefore, the code immediate to a throw statement will not be executed. The control is then transferred to the next catch block or the caller method. The throw Keyword in Java The throw keyword is used to throw an exception manually. Whenever it is required to stop the execution of the functionality based on the user-defined logical error condition, we will use this ... Read More