100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CS2 Midterm - Exam with 100% correct answers 2024/2025 LATEST UPDATE 100% VERIFIED $9.49   Add to cart

Exam (elaborations)

CS2 Midterm - Exam with 100% correct answers 2024/2025 LATEST UPDATE 100% VERIFIED

 5 views  0 purchase
  • Course
  • Navy CS2
  • Institution
  • Navy CS2

CS2 Midterm - Exam with 100% correct answers 2024/2025 LATEST UPDATE 100% VERIFIED

Preview 2 out of 13  pages

  • October 6, 2024
  • 13
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • cs2 midterm
  • Navy CS2
  • Navy CS2
avatar-seller
AnswersCOM
CS2 Midterm
"Imports" java libraries to supply useful methods, data structures, etc

Go at the top of code, outside of class declaration - ANS-Import statements

1. Constant (best) ex: popping stack, looking at an index in an array

2. Log2N (worse, but better than linear) ex: binary search

3. Linear N (worse, but better than quadratic) ex: traversing the entirety of list

4. Quadratic N^2 (worst) ex: traversing a list within a list, double for-loop - ANS-Kinds of Big O

1. HashMap: A map that does hashing stuff. The keys are not sorted, and will seem to be in an
arbitrary, random order.

2. LinkedHashMap: Keys are returned in the order in which they were added to the Map

3. TreeMap: Keys sorted in "natural order," by having keys implement Comparable, or by
supplying a Comparator - ANS-3 types of maps

1. if-else

2. for-loop

3. while-loop

4. switch break - ANS-Control structures

1. Java is compiled: Have to run compiler to turn java code into machine instructions (byte code)
before you run it

2. Java is statically and strictly typed: must explicitly declare type of object or variable (ex: int,
string)

3. Much more verbose

4. Faster b/c it's compiled. Does not need time to interpret code b/c it's already compiled into
machine instructions. - ANS-Java vs Python

1. Java Standard Edition

, 2. Java Runtime Environment : The JVM and additional code for all the libraries included by
default with Java. Lets you run programs but does not let you compile them.

3. Java Development Kit: JRE + JAVAC

4. Java Archive: A zipped-up collection of all the Java classes, metadata, resources needed for
some project. - ANS-1. Java SE

2. JRE

3. JDK

4. JAR

1. Most basic data types that contain the purest, simplest values (ex: int, bool, float)

2. The class that the instantiation belongs to (must be declared w upper case!). Objects must
have declared Class as its type.

3. Reference types (classes) that come by default in java.lang without needing to import (most
important being String, as well as wrappers) - ANS-Data Types

1. Primitive types

2. Reference types

3. Literals

1. No modifier (default): Visible to the package

2. Private: Visible only to the class and not to subclasses nor other packages

.3. Protected: Visible to class and to subclasses, and subclasses in OTHER packages (must be
imported)

4. Public: Visible to all packages (must be imported), classes, subclasses, etc. - ANS-Access
level modifiers

1. Open addressing uses less memory (no lists within an array, just use the space already
allocated)

2. Separate chaining, you'll never run out of memory allocated for the original array... but you
take up more memory

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller AnswersCOM. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $9.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

82215 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$9.49
  • (0)
  Add to cart