MCQs > IT & Programming > Java > Output of the following program? class overload { int x; int y; void add(int a) { x = a + 1; } void add(int a, int b) { x = a + 2; } } class Overload_methods { public static void main(String args[]) { overload obj = new overload(); int a = 0; obj.add(6); System.out.println(obj.x); } }

Java MCQs

What is the output of the following program?

class overload
    {
        int x;
     int y;
        void add(int a)
        {
            x =  a + 1;
        }
        void add(int a, int b)
        {
            x =  a + 2;
        }        
    }    
    class Overload_methods
    {
        public static void main(String args[])
        {
            overload obj = new overload();  
            int a = 0;
            obj.add(6);
            System.out.println(obj.x);    
        }
  }


Answer

Correct Answer: 7

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it