CodeHS Programming Language Accreditations 2 — Questions and Answers
Question 1: In CodeHS Python, what does the `len()` function return when called on a list?
- The largest element in the list
- The number of elements in the list (Correct answer)
- The sum of all elements
- The index of the last element
Correct answer: The number of elements in the list
`len()` returns the count of items in the list.
Question 2: Which Java keyword is used to prevent a class from being subclassed?
- static
- abstract
- final (Correct answer)
- private
Correct answer: final
The `final` keyword on a class declaration prevents inheritance.
Question 3: In JavaScript, what is the output of `typeof null`?
- "null"
- "undefined"
- "object" (Correct answer)
- "boolean"
Correct answer: "object"
`typeof null` returns `"object"` due to a historical bug in JavaScript that was never fixed.
Question 4: Which Python data structure uses key-value pairs?
- List
- Tuple
- Set
- Dictionary (Correct answer)
Correct answer: Dictionary
Dictionaries store data as key-value pairs using curly braces `{}`.
Question 5: In Java, which access modifier makes a member accessible only within the same class?
- protected
- default
- private (Correct answer)
- public
Correct answer: private
The `private` modifier restricts access to the declaring class only.
Question 6: What does CSS stand for in web development?
- Computer Style Sheets
- Cascading Style Sheets (Correct answer)
- Creative Styling Syntax
- Coded Structure System
Correct answer: Cascading Style Sheets
CSS stands for Cascading Style Sheets, used to style HTML documents.
Question 7: In Python, which method removes and returns the last element of a list?
- remove()
- delete()
- pop() (Correct answer)
- discard()
Correct answer: pop()
`pop()` removes the last element (or element at a given index) and returns it.
In CodeHS Python, what does the `len()` function return when called on a list?