Understanding Java Constructors in a Sandwich Shop Program

Understanding Java Constructors in a Sandwich Shop Program

Assessment

Interactive Video

Computers

9th - 10th Grade

Hard

Created by

Jennifer Brown

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What are the instance variables in the sandwich class used for?

To manage the shop's inventory

To calculate the total sales

To store the type of bread used

To represent the sandwich's attributes like meat, cheese, and price

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a Constructor in Java?

To delete objects

To create new objects and set their initial state

To manage memory allocation

To update existing objects

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does a no-argument Constructor mean?

It has no return type

It does not create any objects

It cannot be used in classes

It has no parameters

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When a sandwich object is instantiated, what does the reference variable store?

The object's price

The object's type

The object's address in memory

The object's name

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens to the instance variables when the Constructor is called?

They are ignored

They are given default values

They are deleted

They are set to null