Skills101
← All practice quizzes

Quiz: static, final and Nested Classes

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

When static code runs, what final really locks, and the four kinds of nested classes (static nested, inner, local and anonymous) with the interview questions asked about each.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    class A {
        static { System.out.print("S "); }
        { System.out.print("I "); }
        A() { System.out.print("C "); }
    }
    public class Main {
        public static void main(String[] args) {
            new A();
            new A();
        }
    }
    
  2. Question 2

    When does a static block run?

  3. Question 3

    What does this print?

    import java.util.*;
    public class Main {
        public static void main(String[] args) {
            final List<Integer> list = new ArrayList<>();
            list.add(5);
            list.add(7);
            System.out.println(list.size());
        }
    }
    
  4. Question 4

    Which statement about a blank final field is correct?

  5. Question 5

    How do you create an object of a (non-static) inner class Account declared inside Bank?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →