
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

456 Views
A static variable gets created at the time of class loading even before the execution of a static block and the purpose of the static block is to assign value to the static variables. A static variable stores a value that is shared between all instances of the class it is defined in and a static block is a section of code that gets executed when class is first loaded. If we want any logic that needs to be executed at the time of class loading that logic needs to place inside the static block so that it will be executed ... Read More

723 Views
In PHP, instance methods are the preferable practice over static methods. In any case, it isn't to say that static methods are not helpful, they have a distinct and unique purpose. Here we discuss a comparison between static and instance methods in PHP.Here Note that instance method is always connected to the object of the class while on the other hand static methods always connected with the class.First talk about static method. The static method in PHP is the same as other Object Oriented Programming Languages. Important cases for using the static method in PHP.The static method required to be ... Read More

13K+ Views
The error that occurs at runtime after successful compilation of the Java program is called a runtime error or unchecked exception. It disrupts the normal flow of a program’s execution and terminates the program abruptly.These errors are not detected by the compiler but by JVM. The runtime errors in Java are represented by a class called RuntimeException. In this article, we are going to learn what RuntimeException is and its common types. Also, we will discuss how to handle RuntimeException in Java. What is RuntimeException in Java? In Java, the RuntimeException of the java.lang package is a parent class of ... Read More

529 Views
PHP offers incredible operators to perform operations such as arithmetic, assignment, comparison and many more ...In this article, more importance will be laid on logical operators "&&" and "AND" and will study how they can be utilized based on their precedence. Logical operators "&&" and "AND" produce true-or-false as results, and therefore these are also known as Boolean operators. Before diving into deep let's learn what is "AND" operator? "AND" operator returns true if and only if both the conditions are true. Let's take an example to demonstrate "AND" operator.ExampleOutput:TrueExplanation:Since variable $val1 = 20 and $val2 = 50, the condition $val1 ... Read More

2K+ Views
ClosureOne of the strengths of javascript is closures. Javascript allows nested functions, a function inside a function, to access the variables of parent functions. This process of accessing outer function's variable by an inner function is called a closure. A memory leak occurs when a declared variable is automatically available to the inner nested function and resides in a memory despite it is not referenced in the inner nested function.In the following example 'childFunction' is the inner function defined within the 'parentFunction' the outer function. When a call is made to 'parentFunction' with a parameter "outer val", the outer variable ... Read More

30K+ Views
In Java, an IllegalArgumentException is thrown in order to indicate that a method has been passed an illegal argument. An illegal argument is one that does not meet the required input from user. This exception extends the RuntimeException class and thus, belongs to those exceptions that can be thrown during the operation of the Java Virtual Machine (JVM). It is an unchecked exception and thus, it does not need to be declared in a method's or a constructor's throws clause. Reasons for java.lang.IllegalArgumentException Some of the reasons for IllegalArgumentException in Java is as follows: ... Read More

2K+ Views
Let us first create a MenuBar −JMenuBar menuBar = new JMenuBar(); UIManager.put("MenuBar.background", Color.ORANGE);To create a submenu for a Menu, the following is an example −Examplepackage my; import java.awt.Color; import java.awt.event.KeyEvent; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JRadioButtonMenuItem; import javax.swing.UIManager; public class SwingDemo { public static void main(final String args[]) { JFrame frame = new JFrame("MenuBar Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); UIManager.put("MenuBar.background", Color.ORANGE); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu); ... Read More

340 Views
Create a combo box first and set some values −JComboBox comboBox = new JComboBox(new String[]{"Product1", "Product2", "Product3", "Product4"});Seth the JComboBox for the editor so that the editor uses the combo box −TreeCellEditor editor = new DefaultCellEditor(comboBox); tree.setEditable(true); tree.setCellEditor(editor);The following is an example to create a Default Cell Editor that uses a JComboBox −Examplepackage my; import javax.swing.DefaultCellEditor; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeCellEditor; public class SwingDemo { public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Demo"); DefaultMutableTreeNode node = new DefaultMutableTreeNode("Products"); DefaultMutableTreeNode node1 ... Read More

3K+ Views
In this article, we are going to discuss how to implement quick sort in JavaScript with suitable examples. Quick sort The Quick sort is a divide and conquers algorithm similar to the merge sort. In this, we pick a pivot element and divide the array around the pivot element. There are many ways to pick the pivot element. Always pick the first element as a pivot element. Always pick the last element as a pivot element. (Implemented in the below program) Pick a random element as pivot element Pick the middle element as pivot element. The main process ... Read More

368 Views
To automatically resize a JTree, use the setVisibleRowCount() method in Java. At first, create a node in the tree −DefaultMutableTreeNode node = new DefaultMutableTreeNode("Project");Now, add nodes to the node created above −DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("App"); DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Website"); DefaultMutableTreeNode node3 = new DefaultMutableTreeNode("WebApp"); node.add(node1); node.add(node2); node.add(node3);Now, create more nodes and set them as child nodes for the nodes we creted above −DefaultMutableTreeNode one = new DefaultMutableTreeNode("Learning website"); DefaultMutableTreeNode two = new DefaultMutableTreeNode("Business website"); DefaultMutableTreeNode three = new DefaultMutableTreeNode("News publishing website"); DefaultMutableTreeNode four = new DefaultMutableTreeNode("Android app"); DefaultMutableTreeNode five = new DefaultMutableTreeNode("iOS app"); DefaultMutableTreeNode six = new DefaultMutableTreeNode("Editor ... Read More