Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CS201 – Data Structures and Algorithms (Solved Questions & Answers)

Rating
-
Sold
-
Pages
57
Grade
A+
Uploaded on
07-09-2025
Written in
2025/2026

CS201 – Data Structures and Algorithms (Solved Questions & Answers) 1. What is the output for the Java code segment below? StringBuilder B1 = new StringBuilder("Fun"); StringBuilder B2 = B1; Bd(" Trace"); Bd(" Code"); Sln(BString() + " and " + BString()); a.) Fun and Code b.) Fun Trace and Code c.) Fun Trace and Fun Code d.) Fun Trace and Fun Trace Code e.) Fun Trace Code and Fun Trace Code f.) [Error -- the code will cause an exception] - ANSWER e.) Fun Trace Code and Fun Trace Code 2. Consider Java classes Foo and SubFoo, where SubFoo is a subclass of Foo. Which of the following Java statements are legal? a.) Foo F = new Foo(); b.) SubFoo S = new SubFoo(); c.) Foo F = new SubFoo(); d.) SubFoo S = new Foo(); - ANSWER a.) Foo F = new Foo(); b.) SubFoo S = new SubFoo(); c.) Foo F = new SubFoo(); 3. Which of the following are true with respect to Java interfaces? Indicate ALL true statements. a.) Regular instance methods are all abstract b.) Can have instance variables c.) Can instantiate objects of an interface type d.) A class may implement multiple interfaces - ANSWER a.) Regular instance methods are all abstract d.) A class may implement multiple interfaces 4. What is different in a method to sort an array of String and a method to sort an array of Integer? a.) Nothing is different about them b.) The data is compared differently in an array of String than it is in an array of Integer c.) The fundamental approach to sorting is different in the two types - ANSWER b.) The data is compared differently in an array of String than it is in an array of Integer

Show more Read less
Institution
CS201 – Data Structures And Algorithms
Course
CS201 – Data Structures and Algorithms

Content preview

CS201 – Data Structures and
Algorithms (Solved Questions &
Answers)


1. What is the output for the Java code segment below?

StringBuilder B1 = new StringBuilder("Fun");
StringBuilder B2 = B1;
B1.append(" Trace");
B2.append(" Code"); System.out.println(B1.toString()
+ " and " + B2.toString());

a.) Fun and Code
b.) Fun Trace and Code
c.) Fun Trace and Fun Code
d.) Fun Trace and Fun Trace Code
e.) Fun Trace Code and Fun Trace Code
f.) [Error -- the code will cause an exception] -
ANSWER ✔ e.) Fun Trace Code and Fun Trace Code

,2. Consider Java classes Foo and SubFoo, where
SubFoo is a subclass of Foo. Which of the following
Java statements are legal?

a.) Foo F = new Foo();
b.) SubFoo S = new SubFoo();
c.) Foo F = new SubFoo();
d.) SubFoo S = new Foo(); - ANSWER ✔ a.) Foo F =
new Foo();
b.) SubFoo S = new SubFoo();
c.) Foo F = new SubFoo();

3. Which of the following are true with respect to Java
interfaces? Indicate ALL true statements.

a.) Regular instance methods are all abstract
b.) Can have instance variables
c.) Can instantiate objects of an interface type
d.) A class may implement multiple interfaces -
ANSWER ✔ a.) Regular instance methods are all
abstract
d.) A class may implement multiple interfaces

,4. What is different in a method to sort an array of
String and a method to sort an array of Integer?

a.) Nothing is different about them
b.) The data is compared differently in an array of
String than it is in an array of Integer
c.) The fundamental approach to sorting is different in
the two types - ANSWER ✔ b.) The data is compared
differently in an array of String than it is in an array of
Integer

5. Consider two Java classes, Foo and SubFoo, where
SubFoo is a subclass of Foo. Also consider the
following Java statements:

ArrayList<Foo> L1 = new ArrayList<Foo>();
ArrayList<Foo> L2;

Indicate which of the statements below are legal.
Indicate all legal statements.

a.) L1.add(new Foo());
b.) L1.add(new SubFoo());
c.) L1.add(new String("Hello"));

, d.) L2 = new ArrayList<SubFoo>(); - ANSWER ✔ a.)
L1.add(new Foo());
b.) L1.add(new SubFoo());

6. Which of the following are not legal in Java?

a.) static constants in an interface
b.) instance data in an interface
c.) A class extending more than one superclass
d.) A class implementing more than one interface -
ANSWER ✔ b.) instance data in an interface
c.) A class extending more than once superclass

7. Consider the Java interface
Comparable<T>
What does T represent in this interface?

a.) The type of the object from which compareTo() will
be called
b.) The type of the object passed in to compareTo() [i.e.
the argument type]

Written for

Institution
CS201 – Data Structures and Algorithms
Course
CS201 – Data Structures and Algorithms

Document information

Uploaded on
September 7, 2025
Number of pages
57
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$14.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
TheComputingAcademyQnA

Get to know the seller

Seller avatar
TheComputingAcademyQnA Teachme2-tutor
View profile
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
7 months
Number of followers
0
Documents
22
Last sold
-
TheComputingAcademyQnA

Welcome to ComputingAcademy – your trusted hub for Q&amp;A documents, solved past papers, and study guides in Computing and Information Technology. Whether you are preparing for exams, revising difficult concepts, or looking for quick solutions, you will find clear, accurate, and well-structured answers to help you succeed. What you will find here: Detailed Question &amp; Answer documents Exam-focused solutions to boost grades Easy-to-follow explanations in IT, Computer Science, Programming, and Networking Reliable study resources created with students in mind Who this is for: Computing and IT students Exam preparation Quick reference and revision At ComputingAcademy, learning computing is simplified.

Read more Read less
0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions