Loading

Quipoin Menu

Learn • Practice • Grow

express-js / Express.js Static Files Serving
mcq
Direction: Choose the correct option

Q1.

Which built-in middleware serves static files in Express?
A. express.serve()
B. express.public()
C. express.file()
D. express.static()
Direction: Choose the correct option

Q2.

If you have a file public/css/style.css, how do you serve it using express.static('public')?
A. The file will be accessible at /style.css
B. It won't be served
C. The file will be accessible at /css/style.css
D. The file will be accessible at /public/css/style.css
Direction: Choose the correct option

Q3.

How can you serve static files from a virtual path prefix like /static?
A. app.use(express.static('public', '/static'))
B. app.get('/static', express.static('public'))
C. app.use('/static', express.static('public'))
D. app.static('/static', 'public')
Direction: Choose the correct option

Q4.

What happens if multiple static directories are used and a file exists in both?
A. The first directory where the file is found will serve it
B. All files are combined
C. The last directory will serve it
D. An error occurs
Direction: Choose the correct option

Q5.

Can express.static serve files outside the specified directory?
A. Only with special configuration
B. No, it restricts access to the directory and subdirectories
C. Yes, if you use .. in the path
D. Yes, by default