Ask Question

public class ScopeRules / /Line 1{static final double rate = 10.50; static int z; static double t; public static void main (String[]args) / /Line 7{int num; double x, z; char ch; / / main block ... }public static void one (int f, char g) / /Line 15{/ / block one ... }public static int w; / /Line 20public static void two (int one, int i) / /Line 22{char ch; int a; / /Line 25//block three{int x = 12; / /Line 29/ / ... }//end block three/ / block two ... / /Line 32}}Which of the following identifiers is visible on the line marked / / main block?1. All identifiers are visible in main. 2. local variables of method two3. w (before method two) 4. z (before main)

+5
Answers (1)
  1. 24 May, 18:56
    0
    The following are visible in the main block.

    1. All identifiers are visible in main

    3. w (before method two)

    4. z (before main)

    Explanation:

    1. All the identifiers are visible in the main block because they are declared inside the class and outside the main method. By default, all identifier is declared public which make them accessible anywhere in the class except if declared within a method which give it a local scope.

    3. w (before method two) : w is also visible in the main method as it is also declared in the class and not within a method. Also, w is declared explicitly with the keyword public.

    4. z (before main) : z is also visible in the main method as it is also declared as an identifiers in the field and outside a method. Though, the variable name 'z' was overriden in the main method and reinitialized as a double.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “public class ScopeRules / /Line 1{static final double rate = 10.50; static int z; static double t; public static void main (String[]args) / ...” 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