Chapter:Interfaces - Introduction - Exercises

From Juneday education
Jump to: navigation, search

Exercises

Exercises for "what is an interface" - with a focus on the basics like "what interfaces exist in the API?", "what classes in the API implements some interfaces?" Etc.

Q1

What class does String extend?

Hint: Look at the API specification for String.

Expand using link to the right to see a suggested answer/solution.

The String class in Java extends Object.

Q2

What interfaces does String implement?

Hint: Look at the API specification for String.

Expand using link to the right to see a suggested answer/solution.

The String class in Java implements the following interfaces:

  • Serializable
  • CharSequence
  • Comparable<String>

Q3

What interfaces does File implement?

Hint: Look at the API specification for File.

Expand using link to the right to see a suggested answer/solution.

The File class in Java implements the following interfaces:

  • Serializable
  • Comparable<File>

Q4

What methods does the AudioClip specify?

Hint: Look at the API specification for AudioClip.

Expand using link to the right to see a suggested answer/solution.

The AudioClip class in Java specifies the following methods:

  • void loop() - Starts playing this audio clip in a loop.
  • void play() - Starts playing this audio clip.
  • void stop() - Stops playing this audio clip.

Links

Further reading

Where to go next

Next page is: Interfaces_-_Implementing_an_interface

« PreviousBook TOCNext »