Member-only story

Java 17 Interview Practice Test: Hands-on

javatechonline blog
9 min readDec 28, 2024

--

In this article, we will explore Java 17 Practice Test with hands-on. It incorporates Interview Questions & Answers with detailed explanation. The article covers all types of questions such as concept-based, code-based and scenario-based. Some of the questions are based on features of Java 21 as well. You will have both conceptual & practical knowledge of the topics after going through all the questions.

Java 17 Interview Questions & Answers Explained

Q#1. What is the effect of the following code snippet in Java 17?

public sealed interface Animal permits Dog, Cat { }
public non-sealed class Dog implements Animal { }
public final class Cat implements Animal { }

A) Dog can have subclasses
B) Cat can have subclasses
C) Animal can have additional subclasses outside permits
D) Dog cannot have subclasses

Answer: A) Dog can have subclasses

Explanation:

  • A): Correct. A non-sealed class allows further subclassing.
  • B): Incorrect. final prevents subclassing for Cat.
  • C): Incorrect. Animal can have subclasses inside permits only.
  • D): Incorrect. Since Dog is a non-sealed class, it can have subclasses.

--

--

javatechonline blog
javatechonline blog

Written by javatechonline blog

Java, Spring Boot, Microservices Tutorials

No responses yet