Copyright

How to Use InstanceOf Operator in Java

Instructions:

Choose an answer and hit 'next'. You will receive your score and answers at the end.

question 1 of 3

Consider the following code that upcasts and downcasts variables. Which of the following is the correct use of instance of to make sure the downcast is OK?

Create Your Account To Take This Quiz

As a member, you'll also get unlimited access to over 79,000 lessons in math, English, science, history, and more. Plus, get practice tests, quizzes, and personalized coaching to help you succeed.

Try it risk-free
Try it risk-free for 30 days. Cancel anytime
Already registered? Log in here for access

1. Instanceof returns _____ if the value of the object is null.

2. Consider the following code. Which of the following correctly checks if author is a String array?

Create your account to access this entire worksheet
A Premium account gives you access to all lesson, practice exams, quizzes & worksheets
Access to all video lessons
Quizzes, practice exams & worksheets
Certificate of Completion
Access to instructors
Create an account to get started Create Account

About This Quiz & Worksheet

Use these questions to make sure you understand how to use instanceof when working in Java. You will be quizzed on different ways this command is used.

Quiz & Worksheet Goals

In this quiz you'll find out if you remember:

  • Instanceof returns
  • How to check for a String array
  • Reading Java code regarding instanceof

Skills Practiced

  • Reading comprehension - ensure that you draw the most important information from the material, such as why instanceof would be running a downcast
  • Defining key concepts - ensure that you can accurately define main phrases, such as instanceof and downcast in Java
  • Information recall - access the knowledge you've gained regarding correct uses of instanceof

Additional Learning

For a more complete understanding of Java language, review the lesson titled How to Use InstanceOf Operator in Java. You will learn about:

  • The two possible returns for the instanceof command
  • Examples of instanceof
  • Common uses for instanceof in Java
Support