11 Programming abstractly using interfaces

 

Exam objectives covered in this chapter

What you need to know

[10.1] Create and implement interfaces

How to create interfaces, extend and implement them. The role of interfaces in implementing polymorphism.

The types of methods that can be defined in an interface – abstract, static and default.

Implicit properties of constants and methods defined in an interface.

Challenges with inheriting multiple interfaces.

Implications of modifying methods of an interface – their signature or implementations of default methods.

[10.2] Distinguish class inheritance from interface inheritance including abstract classes

Differences and similarities in inheriting abstract or concrete classes and implementing interfaces.

[10.3] Declare and use List and ArrayList instances

How to declare, create, and use List and  ArrayList. Advantages of using an ArrayList over arrays.

Use of methods that add, modify, and delete elements of an ArrayList.

[10.4] Understanding lambda expressions

Syntax and usage of lambda expressions. Usage of Predicate class.

11.1   Create and implement interfaces

11.1.1 Defining an interface

11.1.2 Identifying when to define interfaces

11.1.3 Types of methods in an interface

11.1.4 Implementing an interface

11.1.5 A class can’t extend multiple classes

11.1.6 A class can implement multiple interfaces

11.1.7 Extending interfaces

11.1.8 Modifying existing methods of an interface

11.2   Class inheritance vs interface inheritance

11.2.1 Essence of inheriting a class vs implementing an interface

11.2.2 Inheriting state

11.2.3 Inheriting behavior

11.2.4 Mandatory implementation of behavior 

11.2.5 Inheriting constructors

11.2.6 Using reference variables of interface or base classes

11.2.7 Multiple inheritance

11.2.8 When to inherit a class or implement an interface

11.3   List and ArrayList

11.3.1 Creating an ArrayList

11.3.2 Adding elements to an ArrayList

11.3.3 Accessing elements of an ArrayList

11.3.4 Modifying the elements of an ArrayList

11.3.5 Deleting the elements of an ArrayList

11.3.6 Other methods of ArrayList

11.4   Lambda expressions

11.4.1 Comparing passing values with passing code to methods

11.4.2 Syntax of lambda expressions

11.4.3 Interface Predicate

11.5   Summary

11.6   Sample exam questions

11.7   Answers to sample exam questions