Skip to main content

Practice ยท 1 of 3

Inventory a class honestly

Inside Solution, define static class Widget { private int a; private String b; public int c; } then: 1. static int declaredFieldCount() โ€” Widget.class.getDeclaredFields().length 2. static int accessibleFieldCount() โ€” Widget.class.getFields().length 3. static boolean knowsPrivate() โ€” true iff one of the DECLARED fields is named "a" (search by name; do not hardcode an index). 4. static String superName() โ€” Widget.class.getSuperclass().getName()

Difficulty: advanced

Back to lesson: Practice: Reflection & DI drills