
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

397 Views
We can able to access the existing object by creating its own prototype using a javascript method called "Object.create()". Using this method we can inherit the properties from the existing properties to the newly created prototype. Let's discuss it in a nutshell.syntaxObject.create(existing obj);This method takes the existing object and creates its own prototype so that the properties will be inherited from the existing object to the newly created prototype.ExampleIn the following example, Initially, an object named "person" is created and the using "Object.create" its own prototype is created and assigned to a variable "newper". Later on, using the prototype the ... Read More

752 Views
String representation of numbers is nothing but converting numeric values into their corresponding string values using methods like toString(). In Java, this can be done by calling the toString() method on wrapper classes such as Integer, Float, and Double. The toString() method is an important method of Object class and it can be used to return the string or textual representation of an object. The object class's toString() method returns a string as the name of the specified object's class which is followed by ?@' sign and the hashcode of the object (java.lang.String;@36f72f09) String Representation Using toString() Method To get ... Read More

183 Views
Boolean functionWhile developing, a developer may come across yes/no situation. At that point of time Boolean() function can be used. It results only in true or false. Let's discuss it in detail.syntaxBoolean(exp);It takes an expression and scrutinizes it and displays either true or false based on the validity of the expression.Example-1In the following example, various values have been checked whether they are true or not using Boolean() function. If any value has any legitimate value then it results in true else it results in false. var a = 0; ... Read More

2K+ Views
A JComboBox is a subclass of JComponent class and it is a combination of a text field and a drop-down list from which the user can choose a value. A JComboBox can generate an ActionListener, ChangeListener, and ItemListener interfaces when the user actions on a combo box.We can implement auto-complete JComboBox when the user types an input value from a keyboard by using customization of a combo box (AutoCompleteComboBox) by extending the JComboBox class.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.plaf.basic.*; public class AutoCompleteComboBoxTest extends JFrame { private JComboBox comboBox; public AutoCompleteComboBoxTest() { setTitle("AutoCompleteComboBox"); ... Read More

282 Views
The run() method of the Thread class is called internally after the start() method is invoked to begin a new thread. However, if the run() method is called directly (without start()), it does not start a separate thread and executes within the current thread. The run() Method In Java, the run() method of the Thread class is used to define the sequence of actions that a thread will execute. This method will be invoked by the Java Virtual Machine (JVM) implicitly; we can also invoke this method explicitly in the current thread without calling the start() method. Note! The run() ... Read More

53K+ Views
Sleep()With the help of sleep() we can make a function to pause execution for a fixed amount of time. In programming languages such as C and PHP we would call sleep(sec). Java has thread.sleep(), Python has time.sleep() and Go has time.Sleep(2 * time.Second).JavaScript doesn't have these kinds of sleep functions. But we should thank promises and async/await function in ES 2018. Because these features have helped us to use sleep() as easy as possible. Let's discuss it in a nutshell.syntax-1sleep(Time in ms).then(() => { //// code })We can use the sleep function with then call back as shown above.syntax-2const work = async () => { await sleep(Time in ... Read More

455 Views
A JDialog is a subclass of Dialog class and it does not hold minimize and maximize buttons at the top right corner of the window. There are two types of dialog boxes namely, modal and non-modal. The default layout for a dialog box is BorderLayout.In the below program, we can implement a transparent JDialog by customizing the AlphaContainer class and override the paintComponent() method.Exampleimport java.awt.*; import javax.swing.*; public class TransparentDialog { public static void main (String[] args) { JDialog dialog = new JDialog(); dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); dialog.getRootPane().setOpaque(false); dialog.setUndecorated(true); dialog.setBackground(new Color (0, 0, ... Read More

670 Views
A String class can be used to represent character strings; all the string literals in Java programs are implemented as instances of the String Class. In Java, Strings are constants and their values cannot be changed (immutable) once declared.Printing Maximum Occurred Character The maximum occurring character of a string refers to the character that appears multiple times (more than any other character in a string) in a string. To count the maximum occurring character of a string, we have the following approaches - Using an Array Using HashMap Using an Array Using an array is one way to ... Read More

3K+ Views
This article will discuss "how to check the memory used by a program" in Java, including a brief introduction of the process for calculation and an appropriate example that correctly checks the memory usage by the program. Understanding Memory Usage in Java Programs A Java code that takes a long time to execute, makes heavy use of dynamic memory. In such scenarios, we may end up with Out-of-Memory errors (due to a memory shortage of the heap space). We can calculate the memory space (heap) used by a Java program using the methods provided by the Runtime class.If the heap space is ... Read More

6K+ Views
SerialVersionUIDThe SerialVersionUID must be declared as a private static final long variable in Java. This number is calculated by the compiler based on the state of the class and the class attributes. This is the number that will help the JVM to identify the state of an object when it reads the state of the object from a file.The SerialVersionUID can be used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible w.r.t serialization. If the deserialization object is different than serialization, then it can throw an InvalidClassException.If the serialVersionUID is ... Read More