Where should the default values of the parameters be specified?
- In a separate header file
- In the function call
- In the function declaration
- In the function definition
Default values of parameters in C++ functions should be specified in the function definition, not in the declaration. This is where you provide the actual implementation of the function, including the default values for its parameters. The declaration merely informs the compiler about the function's signature.
In a switch-case structure, if a case does not have the break keyword, the subsequent cases or blocks will execute until this keyword is encountered.
- Continue
- End
- Skip
- Stop
In a switch-case structure, if a case does not have the break keyword, it will fall through to the subsequent cases or blocks until a break is encountered. The break keyword is essential to exit the switch statement once a case is matched and executed.
Jack has written a C++ program, but when he tries to run it, nothing appears on the screen. What could be missing in his main function?
- #include
directive - cout << "Hello, World!" << endl; statement
- int main() function
- return 0; statement
Jack might be missing the cout << "Hello, World!" << endl; statement within his main() function. Without this line, nothing will be displayed on the screen when he runs the program.
Which of the following is NOT a valid visibility keyword for properties and methods in PHP classes?
- Private
- Protected
- Public
- Final
'Final' is not a visibility keyword; it's used to indicate that a method or class cannot be extended or overridden. The valid visibility keywords are 'private,' 'protected,' and 'public.'
To repeatedly execute a block of code while a condition is true, you would use a ________ loop.
- While
- If
- For
- Switch
In PHP, the 'while' loop is used to execute a block of code repeatedly as long as a specified condition is true. It's great for tasks like iterating through arrays or processing data.
In PHP, the ________ function can be used to replace all occurrences of a search string with a replacement string in a given string.
- replace()
- str_replace()
- modifyString()
- swapString()
The str_replace() function in PHP is used to replace all occurrences of a search string with a replacement string in a given string. This is helpful for text manipulation and data processing tasks.
You are given a task to store student grades for different subjects. Which type of PHP array would be most efficient for this?
- Associative Array
- Numeric Array
- Multidimensional Array
- Linked List
An associative array would be the most efficient for storing student grades for different subjects. It allows you to associate each subject with its respective grade, making it easy to access grades by subject name.
When performing a DELETE operation in SQL, what happens if you omit the WHERE clause?
- All rows are deleted
- An error is thrown
- No rows are deleted
- The table structure is modified
If you omit the WHERE clause in a DELETE operation, it will delete all rows in the table. This is known as a "truncation," and it's a risky operation.
To remove unwanted tags and attributes from a string, you can use the PHP function ________.
- strip_tags
- sanitize_input
- clean_string
- filter_var
The strip_tags function in PHP is used to remove unwanted HTML and PHP tags and attributes from a string.
In a PHP script, you have a PDO prepared statement that updates user information based on user ID. However, sometimes the script fails silently without any error. Which of the following could be a method to diagnose the issue?
- Enable PDO error mode
- Add more SQL queries for error handling
- Increase the PHP memory limit
- Use unprepared SQL queries
Enabling PDO error mode will help identify errors in your SQL statements and provide detailed error messages, aiding in issue diagnosis.