
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

15K+ Views
To get a part of a string, string.substring() method is used in javascript. Using this method we can get any part of a string that is before or after a particular character.str.substring() This method slices a string from a given start index(including) to end index(excluding). If only one index is provided then the method slice the entire string from the start of the index. syntax-1Using this line of code we can get a part of a string after a particular character.string.substring(string.indexOf(character) + 1);syntax-2Using this line of code we can get a part of a string before a particular character.string.substring(0, string.indexOf(character));ExampleLive Demo ... Read More

16K+ Views
In object-oriented programming, coupling is a term used to describe the level of dependency each class or component of an application has on another. Tight coupling in Java means features of different classes and objects have high dependence on one another, whereas Loose coupling means components have very low or no dependency on one another. This article explains how tight coupling is different from loose coupling in Java. Tight Coupling in Java In tight coupling, if the implementation of one class changes, the dependent class might also need to be changed. It makes Java code less flexible and more difficult ... Read More

444 Views
The java.lang.Class is one of the most important class in Java and it can provide several utility methods like getClass(), forName() which is used to find and load a class. It can also provide methods like Class.newInstance() which is the backbone of reflection and allow us to create an instance of a class without using new() operator.Importance of java.lang.ClassInstances of the class Class represent classes, interfaces, enum and annotation in a running Java application.Whenever a java file is compiled, the compiler will insert a public, static, final field named Class of the type java.lang.Class into generated .class fileEach and every class exposes its code in the form of an ... Read More

4K+ Views
Function chainingFunction chaining is nothing but grouping functions in one single line using dot notation. This type of chaining makes the code very concise and also improves the performance.Here we are going to learn function chaining using regular objects.a) Without function chaining In the following example an object 'obj' is created and in that object a public property called 'i' is created using keyword 'this' and initially assigned a value 0. later on user defined functions called add(), subtract() and print() are created inside the same object 'obj'. Now, the object "obj" will acts like a class(it's properties can be shared by ... Read More

12K+ Views
Immutable objects are those objects whose states cannot be changed once initialized. Sometimes it is necessary to make an immutable class as per the requirement. For example, All primitive wrapper classes (Integer, Byte, Long, Float, Double, Character, Boolean and Short) are immutable in Java. String class is also an immutable class.To create a custom immutable class we have to do the following stepsDeclare the class as final so it can’t be extended.Make all fields private so that direct access is not allowed.Do not provide setter methods (methods that modify fields) for variables, so that it can not be set.Make all mutable ... Read More

2K+ Views
Calculating number of vowels in a stringVowels in English language are a, e, i, o and u. Make sure that, in any string these vowels can be both cases ( either small or capital). DebriefThe following example, using a user defined function called 'noOfVowels()', reads an input string and compares that string with another string which contains only vowels( 'aAeEiIoOuU'). It takes the help of indexOf() method to proceed the task. The indexOf() method displays index of a character whenever the character is common to both the strings, in unmatched case it displays '-1' as the output. Here it compares each and ... Read More

4K+ Views
A Type casting in Java is used to convert objects or variables from one data type to another. When we are converting or assigning one data type to another, automatic conversion will take place (if the types are compatible and the conversion is safe). However, if there is a risk of data loss, the conversion must be done explicitly by the programmer. Let's understand the types of Java type casting and the difference between them in this article. Types of Type Casting in Java Java Type Casting is classified into two types, which are: ... Read More

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