ExamVeda
Login
Home
This question belongs to Java Program Exceptions
Exceptions
?

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);
      }
}

Answer & Solution
Correct Answer: Option A
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

3 Comments
Pandì Pandimani
Pandì Pandimani 6 years ago
instead of int we give float mean we get answer 3.5 Iam correct
Mohammad Belal
Mohammad Belal 9 years ago
here integer value is stored and the deimal value will be lost i.e instead of 3.5 it will store 3.
Soumya Priyadarsini
Soumya Priyadarsini 9 years ago
here output is 3 because i is of type int