
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

5K+ Views
No, we cannot define a static constructor in Java, If we are trying to define a constructor with the static keyword a compile-time error will occur.In general, static means class level. A constructor will be used to assign initial values for the instance variables. Both static and constructor are different and opposite to each other. We need to assign initial values for an instance variable we can use a constructor. We need to assign static variables we can use Static Blocks.ExampleLive Demopublic class StaticConstructorTest { int x = 10; // Declaratiopn of Static Constructor static StaticConstructorTest() { ... Read More

12K+ Views
Dependency injection is a procedure where one object supplies the dependencies of another object. Dependency Injection is a software design approach that allows avoiding hard-coding dependencies and makes it possible to change the dependencies both at runtime and compile time.There are numerous approaches to inject objects, here are couple generally known −Constructor InjectionIn this approach, we can inject an object through the class constructor.Example Live DemoOutput3Setter Injectionwhere you inject the object to your class through a setter function.ExampleBenefits of Dependency InjectionAdding a new dependency is as easy as adding a new setter method, which does not interfere with the existing code.Read More

471 Views
The intern() method of String class can be used to deal with the string duplication problems in Java. Using intern() we can save a lot of memory consumed by duplicate string instances. A string is duplicate if it contains the same content as another string but it can be occupied different memory locations.We know that JVM maintains a separate heap memory for string literals for the performance. Once we declare a string literal it will go to this pool and if another variable is assigned with the same literal value, it will be picked from the pool instead of creating a new ... Read More

4K+ Views
Yes, we can change the order of public static void main() to static public void main() in Java, the compiler doesn't throw any compile-time error or runtime error. In Java, we can declare access modifiers in any order, the method name comes last, the return type comes second to last and then after it's our choice. But it's recommended to put access modifier (public, private and protected) at the forefront as per Java coding standards. Java Method Modifiers and Their Order Java allows you to place method modifiers (the keyword "public, " "static, " "final, " etc.) in various orders. The Java ... Read More

4K+ Views
No, we cannot extend an enum in Java. Java enums can extend java.lang.Enum class implicitly, so enum types cannot extend another class.Syntaxpublic abstract class Enum> implements Comparable, Serializable { // some statements }EnumAn Enum type is a special data type which is added in Java 1.5 version.An Enum is used to define a collection of constants, when we need a predefined list of values which do not represent some kind of numeric or textual data, we can use an enum.Enums are constants and by default, they are static and final. so the names of an enum type fields are in uppercase letters.Public or protected modifiers can only ... Read More

2K+ Views
Static blockThe static blocks are executed at the time of class loading.The static blocks are executed before running the main () method.The static blocks don't have any name in its prototype.If we want any logic that needs to be executed at the time of class loading that logic needs to placed inside the static block so that it will be executed at the time of class loading.Syntaxstatic { //some statements }ExampleLive Demopublic class StaticBlockTest { static { System.out.println("Static Block!"); } public static void main(String args[]) { System.out.println("Welcome to Tutorials Point!"); } }OutputStatic Block! ... Read More

338 Views
To convert a string in to date object Date() method should be used. This method creates a date instance that represents a single moment in time in a platform-independent format.ExampleIn the following example a string named "str" is initially parsed using JSON.parse() method and then converted in to date object using Date() method.Live Demo var str = '{"name":"Ram", "DOB":"1980-11-1", "country":"India"}'; var dateObj = JSON.parse(str); dateObj.DOB = new Date(dateObj.DOB); document.write(dateObj.DOB); OutputThu Nov 01 0198 00:00:00 GMT+0553 (India Standard Time)

5K+ Views
Yes, Python support both Object Oriented and Procedural Programming language as it is a high level programming language designed for general purpose programming. Python are multi-paradigm, you can write programs or libraries that are largely procedural, object-oriented, or functional in all of these languages. It depends on what you mean by functional. Python does have some features of a functional language. OOP's concepts like, Classes, Encapsulation, Polymorphism, Inheritance etc.. in Python makes it as a object oriented programming language. In Similar way we can created procedural program through python using loops ,for ,while etc ..and control structure.Exampleclass Rectangle: def __init__(self, length, breadth, ... Read More

388 Views
To delete a property of an object, delete key word should be used. Delete key word can be used with both the methods such as Dot method and Bracket method.syntaxdelete object.property;ExampleIn the following example initially when the property "country" is executed its value "England" is displayed in the output. But when that property is deleted using delete keyword, instead of "England", undefined is displayed as shown in the output.Live Demo var txt = ""; var person = { "name":"Ram", "age":27, "address": { "houseno" : 123, ... Read More

5K+ Views
A method is a collection of statements that are grouped together to perform an operation. In Java, you can define a method having the same name as the class but it is not recommended as per the coding standard. Can We define a Method Having Same as Class? Yes, It is allowed to define a method with the same name as that of a class. There is no compile-time or runtime error will occur. But this is not recommended as per coding standards in Java. Normally the constructor name and class name always the same in Java. Example of a ... Read More