Ask Question

A method variable a class variable with the same name. a) acquiesces to b) destroys c) overrides d) alters

+5
Answers (1)
  1. 24 August, 09:18
    0
    Option (c) is the correct answer for the given question.

    Explanation:

    The method variable overrides the class variable name with same name The method variable overrides of the class variable name.

    Following are the example in java language

    public class Main

    {

    int b=90; / / class varaible or instance varaible

    void sum ()

    {

    int b=34; / / method having same name as class varaible name

    b=b+10;

    System. out. println (b); / / display b

    }

    public static void main (String[] args) / / main method

    {

    Main ob=new Main (); / / craete object

    ob. sum (); / / calling method sum

    }

    }

    Output:

    44

    In this we declared a variable 'b' as int type in class and override this variable in sum () function it means same variable name is declared in function sum ().

    acquiesces, destroys, alters are the wrong for the given question.

    So overrides is the correct answer
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A method variable a class variable with the same name. a) acquiesces to b) destroys c) overrides d) alters ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers