Web services are popular these days because they are language and platform independent. It’s easy to create SOAP and REST based web services. This post will help you learn about web services and related interview questions. Then there are questions with detailed answers forJava Web Services. 7...
8. How to write custom exceptions in Java? We can extendExceptionclass or any of its subclasses to create our custom exception class. The custom exception class can have its own variables and methods that we can use to pass error codes or other exception-related information to the exception ...
publicclassTest{static{// System.out.println(x); CE: illegal forward referencex=100;// we can write}staticintx=200;publicstaticvoidmain(String[]args){System.out.println(x);}} 2. Questions on the Scope of Variables and Methods 2.1. What are actual parameters and formal parameters? The pa...
52) What is Cohesion? Cohesion is about the degree to which a class or a module's responsibilities arerelated. High cohesion — a class does one thing, making it moremaintainable. High cohesionmeans the class has a well-defined purpose and performs a specific task, making it easier to main...
A Package is a collection of related classes and interfaces. 3) What is the superclass of all exception classes? Java.lang.Throwable is the superclass of all exception classes. In Java, all exception classes are derived from this base class. ...
Follow-up questionsThis works well as long as all details related to the attack can be encapsulated in the Weapon subclasses. However, what if the Player needs to perform different actions depending on the weapon type? For example, swing()ing a gun or fire()ing a sword is unlikely to ...
By the way @vinit Sainisuggested a very good point related to this core Java interview question There is a difference when looking at exceptionhandling. If your tasks throws an exception and if it was submitted with execute this exception will go to the uncaught exception handler (when you do...
When the parent class method has a throws clause with an unchecked exception, the child class method can throw none or any number of unchecked exceptions, even though they are not related. Here’s an example that honors the rule: classParent{voiddoSomething()throwsIllegalArgumentException {// ...
Static: This static keyword is used to make main() method as a class related method so that JVM can invoke it without instantiating the class. It is also helpful to avoid unnecessary memory usage with object just for calling main method. Void: The void keyword is used to specify that a ...
it helps you to group related SQL statement into a batch and execute them instead of executing a single query. (the purpose is execute multiple queries which makes it faster) 10 the diff between execute, executeQuery, executeUpdate? Execute: used to execute any SQL query and it returns true ...