Operating System

Tuesday, April 9, 2019

Can we have only try block in Java without catch/finally?

Leave a Comment

Question 
Yes
No

Explanation: try block should have at least catch or finally block with it

public class HelloWorld{

     public static void main(String []args){
        try{
            System.out.println(1/0);
            
        }
     }
}
Above code gives "'try' without 'catch', 'finally' or resource declarations error"
public class HelloWorld{
     public static void main(String []args){
        try{
            System.out.println(1/0);
        }catch(Exception e){
            System.out.println("catch");
        }
     }
}
Above code compiles properly

public class HelloWorld{
     public static void main(String []args){
        try{
            System.out.println("try");
        }finally{
            System.out.println("finally");
        }
     }
}
Above code compiles properly
Read More

Can we have return statement inside finally block?

Leave a Comment
Question 
Yes
NO

Read More

Can we have return statement inside catch block?

Leave a Comment
Question 
Yes
NO

Read More

Can we have return statement inside try block?

Leave a Comment
Question 
Yes
NO
Read More

Monday, July 13, 2015

Which of the given option is NOT TRUE?

Leave a Comment
Which of the given option is  NOT TRUE?
SELECT cannot retrive data from more than one table 
UPDATE command can update only one table at a time 
SAVEPOINT identifies a point in a transaction to which you can later roll back 
INSERT adds data into a table 
Read More

The command to eliminate a table from a database is:________

Leave a Comment
The command to eliminate a table from a database is:________
REMOVE TABLE CUSTOMER; 
DELETE TABLE CUSTOMER; 
DROP TABLE CUSTOMER; 
UPDATE TABLE CUSTOMER; 
Read More

The SQL WHERE clause is ________

Leave a Comment
The SQL WHERE clause is ________
Neither A nor B are correct 
A) limits the column data that are returned. 
B) limits the row data are returned 
Both A and B are correct 
Read More