Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Solved Homework 2 Questions - Introduction to Objective-Oriented Development | CS 1706, Quizzes of Computer Science

online Quiz/HW 2 Material Type: Quiz; Professor: Barnette; Class: Intro Obj-Oriented Development; Subject: Computer Science; University: Virginia Polytechnic Institute And State University; Term: Fall 2006;

Typology: Quizzes

Pre 2010

Uploaded on 11/11/2006

csk-1
csk-1 🇺🇸

19 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download Solved Homework 2 Questions - Introduction to Objective-Oriented Development | CS 1706 and more Quizzes Computer Science in PDF only on Docsity! CS1706 Quiz/HW 2 Fall 2006 1.) A queue follows LIFO. FALSE 2.) When an item is pushed onto a stack, it is added to the top. 3.) For the following code, what is returned? public String testStack() throws EmptyStructureException { String s; Stack<String> stack = new ArrayStack<String>(); stack.push("a"); s = stack.pop(); stack.pop(); stack.push("c"); stack.push(s); stack.push("b"); stack.push("d"); stack.peek(); s = stack.pop(); stack.push(s); return s; } Nothing, an exception is thrown. 4.) When an exception occurs, it must be either handled in a try/catch block or thrown to the current method’s caller. 5.) For the following code, what is returned? public String testStack() throws EmptyStructureException { String s; Stack<String> stack = new ArrayStack<String>(); stack.push("a"); stack.push("b"); s = stack.pop(); stack.push("c"); stack.push(s); stack.push("d"); stack.pop(); s = stack.pop(); return s; } “b” 6.) A stack trace is a listing of all the exceptions thrown during the program. False 7.) For the following code, what is returned? public String testQueue() throws EmptyStructureException { String s; Queue<String> queue = new ArrayQueue<Integer>(); queue.add("a");
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved