Examveda
Examveda

Determine output of the following program code?
public class Test{
      public static void main(String args[]){
            int i;
            try{
                  i = calculate();
                  System.out.println(i);
            }catch(Exception e){
                  System.out.println("Error occured");
            }
      }

      static int calculate(){
            return (7/2);
      }
}

A. 3

B. 3.5

C. Error occured

D. Compilation Error

E. None of these

Answer: Option A


This Question Belongs to Java Program >> Exceptions

Join The Discussion

Comments ( 3 )

  1. Pandì Pandimani
    Pandì Pandimani :
    3 years ago

    instead of int we give float mean we get answer 3.5 Iam correct

  2. Mohammad Belal
    Mohammad Belal :
    6 years ago

    here integer value is stored and the deimal value will be lost i.e instead of 3.5 it will store 3.

  3. Soumya Priyadarsini
    Soumya Priyadarsini :
    7 years ago

    here output is 3 because i is of type int

Related Questions on Exceptions