Ask Question
29 October, 11:40

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

+5
Answers (1)
  1. 29 October, 12:30
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers