Java Stack Class Quiz

Java Stack Class Quiz

12th Grade

14 Qs

quiz-placeholder

Similar activities

Practice for 10th AP Java quiz (old)

Practice for 10th AP Java quiz (old)

10th - 12th Grade

11 Qs

Java Strings

Java Strings

9th - 12th Grade

12 Qs

PCEP Section 4D: Basics of Python Exception Handling

PCEP Section 4D: Basics of Python Exception Handling

12th Grade

15 Qs

Ch 3 Stack

Ch 3 Stack

12th Grade

10 Qs

A Level Computing - Operating Systems 1

A Level Computing - Operating Systems 1

12th Grade

12 Qs

Comprog-October 11, 2022

Comprog-October 11, 2022

11th - 12th Grade

10 Qs

Berfikir Komputesional

Berfikir Komputesional

9th - 12th Grade

10 Qs

Java Stack Class Quiz

Java Stack Class Quiz

Assessment

Quiz

Computers

12th Grade

Medium

Created by

Jay Ho

Used 2+ times

FREE Resource

14 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primary principle on which the Stack class in Java is based?

First-in-first-out (FIFO)

Last-in-first-out (LIFO)

First-in-last-out (FILO)

Last-in-last-out (LILO)

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method is used to add an element to the top of the stack?

add()

insert()

push()

append()

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method is used to remove the top element from the stack?

discard()

pop()

delete()

remove()

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the peek() method do in a Stack?

Returns the top element without removing it

Adds an element to the top

Checks if the stack is empty

Removes the top element

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which interface does the Stack class implement?

Queue

List

Set

Map

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the search() method return if the element is not found in the stack?

null

0

-1

An exception

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code snippet? Stack stack = new Stack<>(); stack.push(1); stack.push(2); System.out.println(stack.pop());

2

An exception

1

null

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?