Raja has Published 760 Articles

When can a .class file get created in Java?

raja

raja

Updated on 03-Jul-2020 08:24:35

1K+ 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 ... Read More

How can we check an underflow occurs in Java?

raja

raja

Updated on 03-Jul-2020 08:19:34

282 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 ... Read More

Can we define a package after the import statement in Java?

raja

raja

Updated on 03-Jul-2020 08:09:50

469 Views

No, we cannot define a package after the import statement in Java. The compiler will throw an error if we are trying to insert a package after the import statement. A package is a group of similar types of classes, interfaces, and sub-packages. To create a class inside a package, declare the ... Read More

How to generate an UnsupportedOperationException in Java?

raja

raja

Updated on 03-Jul-2020 07:45:55

392 Views

An UnsupportedOperationException is a subclass of RuntimException 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.Syntaxpublic class UnsupportedOperationException ... Read More

Importance of the getCause() method in Java?

raja

raja

Updated on 03-Jul-2020 07:40:44

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 ... Read More

How does a ClassLoader work in Java?

raja

raja

Updated on 03-Jul-2020 07:39:59

813 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 ... Read More

Can we have an empty catch block in Java?

raja

raja

Updated on 03-Jul-2020 07:18:31

5K+ 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 ... Read More

What are the uses of generic collections in Java?

raja

raja

Updated on 03-Jul-2020 05:57:29

6K+ Views

The generic collections are introduced in Java 5 Version. The generic collections disable the type-casting and there is no use of type-casting when it is used in generics. The generic collections are type-safe and checked at compile-time. These generic collections allow the datatypes to pass as parameters to classes. The Compiler is responsible for checking the ... Read More

How can we disable the leaf of JTree in Java?

raja

raja

Updated on 03-Jul-2020 05:46:15

261 Views

A JTree is a component that presents a hierarchical view of data. The user has the ability to expand or collapse individual sub-trees. A TreeNode interface defines the methods that must be implemented nodes of a JTree object. The DefaulMutableTreeNode class provides a default implementation of a TreeNode interface. We can disable the leaf of JTree by ... Read More

How can we remove a selected row from a JTable in Java?

raja

raja

Updated on 02-Jul-2020 13:12:48

6K+ Views

A JTable is a subclass of JComponent class for displaying complex data structures. A JTable component can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns. A JTable can generate TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener and RowSorterListener interfaces. We can remove a selected row from a JTable ... Read More

Advertisements