Programming Language Accreditations Flashcards
5 cards from real CODEHS practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 5 Programming Language Accreditations flashcards as text
Which of the following is the correct syntax for defining a function in Python?
Answer: def myFunction():
In Python, functions are defined using the `def` keyword, followed by the function name, parentheses `()`, and a colon `:`. The code block belonging to the function is then indented below this definition line. This syntax clearly distinguishes function definitions from other code structures and is fundamental to Python programming.
What is the primary purpose of the 'var' keyword in JavaScript?
Answer: To declare a variable with a function scope
In JavaScript, the `var` keyword is used to declare variables that are scoped to the function in which they are declared. This means the variable is accessible anywhere within that function, but not outside of it. While `var` can also create global variables if declared outside any function, its primary characteristic is function-level scoping, unlike `let` and `const` which are block-scoped.
Which data type is used for storing text in Java?
Answer: String
In Java, the `String` class is specifically designed to store sequences of characters, which represent text. Unlike `char`, which holds a single character, `String` objects are immutable and can hold any length of text. It is one of the most commonly used data types for handling textual data in Java applications.
What does the ++ operator do in C++?
Answer: Increments the value of a variable by 1
The `++` operator in C++ is the increment operator. It is a unary operator that increases the value of its operand by one. For example, if `x` is 5, then `x++` or `++x` will change the value of `x` to 6. This operator is commonly used in loops and for simple counting operations.
Which of the following is true about the Python keyword 'self'?
Answer: It refers to the instance of the class in object-oriented programming
In Python, `self` is a convention used as the first parameter in instance methods within a class. It explicitly refers to the instance of the class on which the method is being called, allowing access to the instance's attributes and other methods. While not a keyword in the strictest sense, it is a crucial and universally adopted identifier for referring to the object itself within its own methods.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy
Sources & references
Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy
- help.codehs.com — Test delivery, exam format, score release, time limit, eligibility, fees, passing score, retake policy, score validity, exam information · verified Oct 2026