
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

4K+ Views
Java provides two classes for having random numbers generation - SecureRandom.java and Random.java.The random numbers can be used generally for encryption key or session key or simply password on web server.SecureRandom is under java.security package while Random.java comes under java.util package.The basic and important difference between both is SecureRandom generate more non predictable random numbers as it implements Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) as compare to Random class which uses Linear Congruential Generator (LCG).A important point to mention here is SecureRandom is subclass of Random class and inherits its all method such as nextBoolean(), nextDouble(), nextFloat(), nextGaussian(), nextInt() and ... Read More

2K+ Views
In this article, we will learn to find unique words in a string using the Map utility of Java because of its property that it does not contain duplicate keys. To find unique words first get all words in the array to compare each word, for this split string based on space/s. If other characters such as comma(, ) or full stop (.) are present then using required regex first replace these characters from the string. Insert each word of string as the key of Map and provide the initial value corresponding to each key as is unique if this ... Read More

746 Views
To count occurence of vowels in a string again use Map utility of java as used in calculating occurence of each character in string.Put each vowel as key in Map and put initial value as 1 for each key.Now compare each character with key of map if a character matches with a key then increase its corresponding value by 1.Examplepublic class OccurenceVowel { public static void main(String[] args) { String str = "AEAIOG"; LinkedHashMap hMap = new LinkedHashMap(); hMap.put('A', 0); hMap.put('E', 0); hMap.put('I', 0); hMap.put('O', 0); hMap.put('U', 0); for (int i = 0; i

32K+ Views
In this post we will try to print an array or matrix of numbers at console in same manner as we generally write on paper.For this the logic is to access each element of array one by one and make them print separated by a space and when row get to end in matrix then we will also change the row.Example Live Demopublic class Print2DArray { public static void main(String[] args) { final int[][] matrix = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; for (int i = 0; i

2K+ Views
In Java Immutable class is a class which once created and it's contents can not be changed.On same concept Immutable objects are the objects whose state can not be changed once constructed.Wrapper classes are made to be immutable due to following advantages −Since the state of the immutable objects can not be changed once they are created they are automatically synchronized.Immutable objects are automatically thread-safe, the overhead caused due to use of synchronisation is avoided.Once created the state of the wrapper class immutable object can not be changed so there is no possibility of them getting into an inconsistent state.The ... Read More

5K+ Views
As we know that in Java POJO refers to the Plain old Java object.POJO and Bean class in Java shares some common features which are as follows −Both classes must be public i.e accessible to all.Properties or variables defined in both classes must be private i.e. can't be accessed directly.Both classes must have default constructor i.e no argument constructor.Public Getter and Setter must be present in both the classes in order to access the variables/properties.The only difference between both the classes is Java make java beans objects serialized so that the state of a bean class could be preserved in ... Read More

527 Views
POJI is an acronym for Plain Old Java Interface which corresponds to a Java standard interface which means that these interfaces are in the context of providing services in JEE. For example, OSGI service is offered through POJI in JEEIn other terms we can say that POJI is an ordinary interface without any specialty that is not inherited from any of the technology API specific interfaces or framework interfaces.Exampleinterface myCustomInterface { public void myMethod(); } interface mySecondCustomInterface extends myCustomInterface { public void mySecondMethod(); }Both interfaces would be called as POJI as they do not inherit any technology specific ... Read More

5K+ Views
As we know it is core concept that in Java there is always pass by value and not by pass by reference.So in this post we will focus on that how this concept get validated in case of passing primitive and passing reference to a method.In case when a primitive type is passed to a method as argument then the value assigned to this primitive is get passed to the method and that value becomes local to that method, which means that any change to that value by the method would not change the value of primitive that you have ... Read More

2K+ Views
The constructor chaining is a specific sequence of calling constructors when a user initializes an object in a certain way. This technique is used when multiple constructors are invoked one after another, based on the instance class. It is also closely related to inheritance, where the role of a subclass constructor is to call the constructor of its superclass. You can perform constructor chaining in two ways: Within the same class - where one constructor calls another constructor of the same class. Across different classes - where a subclass constructor calls ... Read More

4K+ Views
There are five main memory areas which are used to various Java elements. Following is the list of the same. Class Area - This area contains the static members of the class. Method Area - This area contains the method definition and executable code. Heap Area - This area contains the objects which are dynamically allocated/deallocated. if an object is no more referenced by any live reference it is deallocated. Stack Area - This area contains the local variables. Pool Area - Contains immutable objects like string.