Web Application Development MCQs with Answers
Practice important Web Application Development MCQs with answers and explanations.
Chapter: 12
Q141:
Fill in the blank: The UPDATE table_name SET column1=value WHERE some_column=some_value statement will _______.
A. delete records
B. create a new table
C. update existing records
D. select records
Correct Answer:
C
Chapter: 12
Q142:
What is the result of running SELECT id, firstname, lastname FROM student?
A. Returns all columns from the table
B. Returns only the id, firstname, and lastname columns
C. Deletes records from the table
D. Updates the records in the table
Correct Answer:
B
Chapter: 12
Q143:
Fill in the blank: The SQL query DELETE FROM student WHERE id=3 will _______.
A. insert a new record
B. update a record
C. delete the record with id 3
D. select records with id 3
Correct Answer:
C
Chapter: 12
Q144:
Which PHP function is used to execute a SQL statement in MySQL?
A. mysqli_query()
B. mysqli_execute()
C. mysqli_prepare()
D. mysqli_fetch()
Correct Answer:
A
Chapter: 12
Q145:
Fill in the blank: To fetch a result row from a MySQL query as an associative array, use _______.
A. mysqli_fetch_assoc()
B. mysqli_query()
C. mysqli_prepare()
D. mysqli_fetch_array()
Correct Answer:
A
Chapter: 13
Q146:
What does the readfile() function do in PHP?
A. Deletes a file
B. Reads a file and writes it to the output buffer
C. Opens a file for writing
D. Closes a file
Correct Answer:
B
Chapter: 13
Q147:
Fill in the blank: The fopen() function in PHP is used to _______.
A. read a file
B. open a file
C. delete a file
D. close a file
Correct Answer:
B
Chapter: 13
Q148:
What is the purpose of the fclose() function in PHP?
A. To open a file
B. To delete a file
C. To close an open file
D. To read data from a file
Correct Answer:
C
Chapter: 13
Q149:
Fill in the blank: The fgets() function reads _______ from a file.
A. a single character
B. a single line
C. the entire file
D. multiple lines
Correct Answer:
B
Chapter: 13
Q150:
How do you read a file character by character in PHP?
A. Using fread()
B. Using fgets()
C. Using fgetc()
D. Using readfile()
Correct Answer:
C
Chapter: 13
Q151:
Fill in the blank: To read a single line from a file, use the _______ function.
A. fwrite()
B. fgets()
C. fread()
D. feof()
Correct Answer:
B
Chapter: 13
Q152:
What function is used to output the contents of a file line by line until end-of-file?
A. fopen()
B. fclose()
C. fgets() and feof()
D. fread()
Correct Answer:
C
Chapter: 13
Q153:
Fill in the blank: To handle files carefully in PHP, avoid _______.
A. editing the wrong file
B. creating files
C. reading files
D. deleting files
Correct Answer:
A
Chapter: 13
Q154:
Which PHP function should be used to handle file reading and writing operations with more options?
A. readfile()
B. fopen()
C. fgetc()
D. fclose()
Correct Answer:
B
Chapter: 13
Q155:
Fill in the blank: The fread() function requires two parameters: the file name and the _______.
A. file mode
B. maximum number of bytes to read
C. file pointer
D. file content
Correct Answer:
B
Chapter: 13
Q156:
What is a common error to avoid when manipulating files in PHP?
A. Reading a file
B. Opening a file
C. Editing the wrong file
D. Using the correct file mode
Correct Answer:
C
Chapter: 14
Q157:
What function is used to create a file in PHP?
A. fopen()
B. fclose()
C. fwrite()
D. unlink()
Correct Answer:
A
Chapter: 14
Q158:
If you open a file using fopen() in PHP with mode "w", what happens to the existing data in the file?
A. Data is appended
B. Data is erased
C. Data is preserved
D. Data is encrypted
Correct Answer:
B
Chapter: 14
Q159:
Which PHP function is used to write data into a file?
A. fwrite()
B. fopen()
C. fclose()
D. file_exists()
Correct Answer:
A
Chapter: 14
Q160:
How do you specify a file to be opened for writing in PHP?
A. fopen("file.txt", "r")
B. fopen("file.txt", "w")
C. fopen("file.txt", "a")
D. fopen("file.txt", "x")
Correct Answer:
B