
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

2K+ Views
A Java class file has a ".class" extension and contains the Java bytecode. This class file can be executed by the Java Virtual Machine (JVM). A ".class" file is created as a result of successful compilation by the Java compiler from the ".java" file. Each class in the .java file is compiled into a separate class file if the ".java " file has more than one class.Exampleclass A { A() { System.out.println("This is class A"); } } class B { B() { System.out.println("This is class B"); } } class C { ... Read More

396 Views
When a value is assigned to a variable that is less than the minimum allowed value for that variable, then an underflow occurs. There is no exception thrown by the JVM if an underflow occurs in Java and it is the responsibility of a programmer to handle the underflow conditions.Examplepublic class UnderlowTest { public static void main(String[] args) { int num1 = -2147483648; int num2 = -1; System.out.println("Number 1: " + num1); System.out.println("Number 2: " + num2); long sum = (long)num1 + (long)num2; ... Read More

4K+ Views
A JTable provides a very flexible possibility to create and display tables. The TableModel interface defines methods for objects that specify the contents of a table. The AbstractTableModel class is typically extended to provide a custom implementation of a model table. A JTable class provides the ability to edit tables using the method setCellEditor() allows an object of the TableCellEditor interface.We can filter a table using the setRowFilter() method of TableRowSorter class.Exampleimport java.awt.*; import java.awt.event.*; import java.util.regex.*; import javax.swing.*; import javax.swing.table.*; public class FilterTableTest extends JFrame { private JTable table; private TableModel model; public FilterTableTest() { setTitle("FilterTable Test"); ... Read More

914 Views
No, the "this" keyword cannot be used to refer to the static members of a class. This is because the “this” keyword points to the current object of the class and the static member does not need any object to be called. The static member of a class can be accessed directly without creating an object in Java. Example public class StaticTest { static int a = 50; static int b; static void show() { System.out.println("Inside the show() method"); b = a + 5; ... Read More

82K+ Views
In Java, we can compare two dates using the compareTo() method of the Comparable interface. This is a common way to compare two dates, and this method returns an integer value based on which you can specify which date occurs before, after, or if it is equal. Here are the return values by this method, based on which you verify the date appearance: ... Read More

6K+ Views
Inter-thread communication involves the communication of threads with each other. The three methods that are used to implement inter-thread communication in Java. wait() This method causes the current thread to release the lock. This is done until a specific amount of time has passed or another thread calls the notify() or notifyAll() method for this object. notify() This method wakes a single thread out of multiple threads on the current object’s monitor. The choice of thread is arbitrary. notifyAll() This method wakes up all the threads that are on the current object’s monitor. Example class BankClient { int balAmount = 5000; synchronized void withdrawMoney(int ... Read More

937 Views
A Java Class is stored in the form of byte code in a .class file after it is compiled. The ClassLoader loads the class of the Java program into memory when it is required. The ClassLoader is hierarchical and so if there is a request to load a class, it is delegated to the parent class loader.The types of ClassLoader in Java are given as followsBootstrap ClassLoaderExtensions ClassLoaderSystem ClassLoaderExamplepublic class ClassLoaderTest { public static void main(String[] args) { System.out.println("class loader for this class: " + ClassLoaderTest.class.getClassLoader()); System.out.println("class loader for DNSNameService: " + sun.net.spi.nameservice.dns.DNSNameService.class.getClassLoader()); ... Read More

2K+ Views
The getCause() method is from Throwable class and we can use this method which returns the cause of the exception or returns null if the cause of the exception is not known. The getCause() method doesn’t accept any arguments and doesn’t throw an exception. It returns the cause that was provided by one of its constructors or that was determined by the formation of the initCause() method of Throwable class.Syntaxpublic Throwable getCause()Examplepublic class GetCauseMethodTest { public static void main(String[] args) throws Exception { try { myException(); } catch(Exception e) { System.out.println("Cause ... Read More

493 Views
In Java, an exception is an event that occurs during the execution of a program. When an Exception occurs, the normal flow of the program is disrupted, and the program/application terminates abnormally, which is not recommended; therefore, these exceptions can be handled. What is UnsupportedOperationException in Java? An UnsupportedOperationException is a subclass of the RuntimException class in Java, and it can be thrown to indicate that the requested operation is not supported. The UnsupportedOperationException class is a member of the Java Collections Framework. This exception is thrown by almost all of the concrete collections like List, Queue, Set, and Map. ... Read More

6K+ Views
Yes, we can have an empty catch block. But this is a bad practice to implement in Java.Generally, the try block has the code which is capable of producing exceptions, if anything wrong in the try block, for instance, divide by zero, file not found, etc. It will generate an exception that is caught by the catch block. The catch block catches and handles the exception. If the catch block is empty then we will have no idea what went wrong within our code.Examplepublic class EmptyCatchBlockTest { public static void main(String[] args) { try { int a ... Read More