Unit 1: Fundamentals of Next.js and Routing - Practice Quiz

INT257 — Modern Web Application Development 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is Next.js?

Introduction to Next.js Easy
A. A relational database system
B. A package manager for JavaScript
C. A framework built on React
D. A CSS preprocessing language

2 Which programming library is the foundation of Next.js?

Introduction to Next.js Easy
A. React
B. Svelte
C. Angular
D. Vue

3 Which feature can Next.js use to generate HTML on the server for each request?

Features of Next.js Easy
A. Database replication
B. Browser extension management
C. CSS preprocessing
D. Server-side rendering

4 Which Next.js component provides automatic image optimization?

Features of Next.js Easy
A. <Image>
B. <Form>
C. <Script>
D. <Head>

5 Which directory commonly contains routes when using the Next.js App Router?

Project Structure Easy
A. public
B. node_modules, which contains all route definitions written by the developer
C. app
D. styles

6 What is the main purpose of the public directory in a Next.js project?

Project Structure Easy
A. To store database queries
B. To store static assets
C. To define dynamic routes
D. To configure React components

7 Which file normally defines the UI for a route in the App Router?

App Router Easy
A. screen.json
B. route.css
C. page.js
D. component.config.js, which registers every component used across the application

8 In the App Router, what does each folder inside the app directory usually represent?

App Router Easy
A. A CSS selector
B. A database table
C. A route segment
D. A package dependency

9 Which command commonly starts a Next.js development server?

Development Workflow Easy
A. npm run lint
B. npm run dev
C. npm run build
D. npm run export

10 What usually happens when a developer saves a file while the Next.js development server is running?

Development Workflow Easy
A. The project is deleted
B. The database is reset
C. The browser reflects the update
D. The application is permanently deployed to a production server

11 What determines a URL path in Next.js file-based routing?

File-based Routing Easy
A. The folder and file structure
B. The component's background color
C. The number of installed packages
D. The order of CSS declarations

12 Which file path creates the /about route with the App Router?

File-based Routing Easy
A. components/routes/about/index.js, followed by manual registration in a central router
B. app/page/about.js
C. public/about/page.js
D. app/about/page.js

13 Which folder name defines a dynamic id route segment?

Dynamic Routes Easy
A. <id>
B. (id)
C. [id]
D. {id}

14 What can the route app/products/[id]/page.js match?

Dynamic Routes Easy
A. /products/42/details/reviews without any additional route segments
B. /42/products
C. /products/42
D. /products only

15 Which folder structure creates the nested route /dashboard/settings?

Nested Routes Easy
A. app/dashboard/settings/page.js
B. app/settings/dashboard/page.js
C. public/dashboard/settings.js
D. app/dashboard/page/settings/layout.js, with the final segment stored inside the layout file

16 What is a layout mainly used for in the Next.js App Router?

Layouts Easy
A. Creating database indexes
B. Replacing every route with a single static HTML document
C. Installing project packages
D. Sharing UI across pages

17 Which file defines a layout in the App Router?

Layouts Easy
A. layout.js
B. wrapper.json
C. shared-page.config.js
D. template.css

18 Which Next.js component is commonly used for client-side navigation between pages?

Navigation Easy
A. Link
B. Script
C. Metadata, which creates navigation links and automatically handles every route transition
D. Image

19 Which special file displays a loading state for a route segment?

Error and Loading UI Easy
A. loading.js
B. wait.config.js
C. pending.js
D. spinner.js

20 Which special file provides an error boundary UI for a route segment?

Error and Loading UI Easy
A. exception-handler.config.js, which must manually register all possible browser and server errors
B. error.js
C. warning.js
D. failure.js

21 A team wants to build a React application with server rendering, routing, and production build optimization without configuring each capability separately. Why is Next.js suitable for this project?

Introduction to Next.js Medium
A. It stores application data without an external database
B. It provides an integrated framework for common React application requirements
C. It replaces React components with static HTML templates
D. It requires all application logic to run in the browser

22 A product page must display current inventory when requested while keeping most rendering work on the server. Which Next.js capability best supports this requirement?

Features of Next.js Medium
A. Client-only rendering with browser storage
B. CSS Modules with component-level styles
C. Server-side rendering with Server Components
D. Static HTML without server execution

23 In an App Router project, which structure creates a home page and a shared root layout?

Project Structure Medium
A. src/index.js and src/wrapper.js
B. app/page.js and app/layout.js
C. pages/page.js and pages/layout.js
D. app/index.js and app/template.js

24 A component under the app directory uses useState and handles a button click. What must be added to the component file?

App Router Medium
A. An exported metadata object
B. The "use client" directive
C. The "use server" directive
D. An exported runtime constant

25 After creating a Next.js project, a developer runs npm run dev and edits app/page.js. What behavior should normally occur?

Development Workflow Medium
A. The development page updates without a production rebuild
B. The browser ignores changes until dependencies are reinstalled
C. The source file compiles only after running npm start
D. The project exports static HTML after every saved change

26 A developer creates app/contact/page.js. Which URL renders that page?

File-based Routing Medium
A. /app/contact
B. /contact
C. /page/contact
D. /contact/page

27 A store needs product URLs such as /products/42 and /products/105. Which file path should define the product page?

Dynamic Routes Medium
A. app/products/id/[page].js
B. app/[products]/id/page.js
C. app/products/[id]/page.js
D. app/products/{id}/page.js

28 Given app/blog/[slug]/page.js, which value should params.slug contain when a user visits /blog/next-routing?

Dynamic Routes Medium
A. blog
B. next-routing
C. slug
D. /blog/next-routing

29 A documentation site must match /docs/setup as well as /docs/setup/windows. Which route definition captures one or more segments after /docs?

Dynamic Routes Medium
A. app/docs/[...parts]/page.js
B. app/docs/(...parts)/page.js
C. app/docs/[[parts]]/page.js
D. app/docs/[parts]/page.js

30 A dashboard needs a settings page at /dashboard/settings. Which directory structure maps directly to that URL?

Nested Routes Medium
A. app/dashboard/[settings]/page.js
B. app/dashboard/settings/page.js
C. app/dashboard/page/settings.js
D. app/settings/dashboard/page.js

31 A team places an admin page at app/(internal)/admin/page.js. What URL should expose the page?

Nested Routes Medium
A. /app/admin
B. /internal/admin
C. /(internal)/admin
D. /admin

32 A navigation sidebar should persist while users move between /dashboard/reports and /dashboard/settings. Where should the sidebar usually be defined?

Layouts Medium
A. app/layout/dashboard.js
B. app/dashboard/page.js
C. app/dashboard/layout.js
D. app/dashboard/loading.js

33 What must a root layout component include so that route content can appear inside its shared HTML structure?

Layouts Medium
A. A children prop rendered in the body
B. A params prop rendered in the head
C. A router prop rendered in the main element
D. A pages prop rendered in the footer

34 A header links to /dashboard and should use client-side navigation with Next.js prefetching support. Which implementation is most appropriate?

Navigation Medium
A. <a route="/dashboard">Dashboard</a>
B. <button href="/dashboard">Dashboard</button>
C. <Nav path="/dashboard">Dashboard</Nav>
D. <Link href="/dashboard">Dashboard</Link>

35 A Client Component must redirect to /checkout only after a form is successfully submitted. Which App Router API is appropriate?

Navigation Medium
A. useRouter().push("/checkout")
B. usePathname().push("/checkout")
C. useSearchParams().push("/checkout")
D. useParams().push("/checkout")

36 A Client Component highlights a menu item when its URL matches the current route. Which hook should it use to read the current pathname?

Navigation Medium
A. useParams
B. useRouter
C. useSearchParams
D. usePathname

37 A route segment performs slow data fetching. Which file provides an immediate fallback while that segment's content is loading?

Error and Loading UI Medium
A. fallback.js
B. pending.js
C. loading.js
D. status.js

38 A dashboard route needs to catch rendering errors in its segment and offer a retry button. Which setup is appropriate?

Error and Loading UI Medium
A. Create app/dashboard/error.js as a Client Component and call reset()
B. Create app/dashboard/loading.js as a Server Component and call retry()
C. Create app/dashboard/layout.js as a Client Component and call reload()
D. Create app/dashboard/page.js as a Server Component and call recover()

39 A component is reused by several routes but should not create a URL of its own. Where can it be placed within an App Router project?

Project Structure Medium
A. In a private folder such as app/_components
B. In a dynamic folder such as app/[components]
C. In a loading file such as app/components/loading.js
D. In a route file such as app/components/page.js

40 A page displays an image whose dimensions vary across devices, and the team wants built-in resizing and lazy loading. Which Next.js feature should be used?

Features of Next.js Medium
A. The Head component from next/head
B. The Script component from next/script
C. The Link component from next/link
D. The Image component from next/image

41 A team is migrating a React single-page application to Next.js. One page must read directly from a database, keep credentials off the browser bundle, and send rendered HTML without creating a separate REST endpoint. Which Next.js design best satisfies these requirements?

Introduction to Next.js Hard
A. Fetch the database from a Client Component during useEffect
B. Query the database directly from an async Server Component
C. Query the database from middleware and inject the complete HTML
D. Place the credentials in a NEXT_PUBLIC_ environment variable

42 An App Router page contains a large data-access library and a small interactive counter. Which component boundary most effectively minimizes client-side JavaScript while preserving interactivity?

Features of Next.js Hard
A. Use a Client Component for data access and a Server Component for the counter
B. Mark the root layout as a Client Component and render the page beneath it
C. Mark the page as a Client Component and import both modules there
D. Keep the page server-rendered and isolate the counter in a Client Component

43 A project uses src/app/page.tsx, src/components/Nav.tsx, and public/logo.svg. Which reference correctly renders the logo regardless of the source file's depth?

Project Structure Hard
A. <img src="/public/logo.svg" alt="Logo" />
B. <img src="../public/logo.svg" alt="Logo" />
C. <img src="src/public/logo.svg" alt="Logo" />
D. <img src="/logo.svg" alt="Logo" />

44 A repository accidentally contains both app/page.tsx and src/app/page.tsx, while configuration files remain at the repository root. What is the correct architectural conclusion?

Project Structure Hard
A. Only one application directory location should be used for the route tree
B. The root app supplies layouts while src/app supplies pages
C. Both route trees are mounted, with src/app available under /src
D. Both route trees are merged, with src/app taking precedence on conflicts

45 A Server Component needs to render an interactive search box that uses state and browser event handlers. Which composition is valid under the App Router?

App Router Hard
A. Call the state hook in the layout and pass its setter through metadata
B. Move the search box into a file beginning with "use client"
C. Add useState directly to the Server Component without a directive
D. Add "use server" to the search box before calling useState

46 A developer adds "use client" to app/dashboard/layout.tsx and imports several utility modules from it. What is the most important consequence?

App Router Hard
A. Its imported component graph enters the client module boundary
B. The layout stops persisting during dashboard navigation
C. All nested pages lose access to server-rendered HTML
D. Every route in the application becomes statically generated

47 During next dev, editing a component sometimes preserves its local state and sometimes remounts it. Which statement best describes the expected behavior?

Development Workflow Hard
A. Fast Refresh attempts preservation but remounts when it cannot do so safely
B. State is preserved only when the edited component is a Server Component
C. Fast Refresh always preserves state for every source-code edit
D. State is discarded unless the browser's HTTP cache contains the module

48 A route works under next dev but fails only when preparing a production deployment. Which command sequence most directly tests the production compilation and runtime behavior locally?

Development Workflow Hard
A. next dev followed by next export
B. next build followed by next start
C. next lint followed by next dev
D. next start followed by next build

49 Given app/page.tsx, app/about/page.tsx, app/about/team.tsx, and app/contact/layout.tsx, which URL set is directly routable from these files?

File-based Routing Hard
A. Only / and /about
B. Only /, /about, and /about/team
C. Only /, /about, and /contact
D. Only /about/team and /contact

50 A project contains app/(marketing)/about/page.tsx. What public URL is produced, assuming no conflicting route exists?

File-based Routing Hard
A. /about
B. /(marketing)/about
C. /about/marketing
D. /marketing/about

51 A segment contains both app/blog/[slug]/page.tsx and app/blog/archive/page.tsx. Which component handles a request for /blog/archive?

Dynamic Routes Hard
A. Both pages, composed according to filesystem order
B. The archive page because static segments have precedence
C. Neither page because the two route patterns conflict
D. The [slug] page with slug equal to archive

52 For a route defined as app/docs/[[...parts]]/page.tsx, which request can match with parts absent rather than containing one or more strings?

Dynamic Routes Hard
A. /docs
B. /docs/api/auth/login
C. /docs/api/auth
D. /docs/api

53 A developer wants /shop to show the shop index while /shop/a/b captures a and b in one route parameter. Which route structure supports both without a separate /shop page?

Dynamic Routes Hard
A. app/shop/[slug]/page.tsx
B. app/shop/[...slug]/page.tsx
C. app/shop/[[...slug]]/page.tsx
D. app/[shop]/[...slug]/page.tsx

54 Given app/dashboard/settings/profile/page.tsx, which directories may define layouts that naturally wrap the profile page without changing its URL?

Nested Routes Hard
A. Only the directory immediately containing page.tsx
B. Only app/dashboard and app/dashboard/settings
C. Only app and app/dashboard/settings/profile
D. app, dashboard, settings, and profile segments

55 Two teams create app/(store)/products/page.tsx and app/(catalog)/products/page.tsx. Why is this structure invalid?

Nested Routes Hard
A. Only one parenthesized directory may exist under app
B. Both files resolve to the same public route /products
C. A products segment must be dynamic inside a route group
D. Route groups may contain layouts but may not contain pages

56 A shared dashboard layout fetches user data and renders a sidebar. When navigating between /dashboard/analytics and /dashboard/settings with Next.js navigation, which behavior should the developer design for?

Layouts Hard
A. The sidebar persists only when both pages are Client Components
B. The shared layout is preserved while the changing child segment updates
C. The shared layout must unmount before every child route can render
D. The root layout persists but every nested layout always remounts

57 An App Router application defines its required root layout in app/layout.tsx. Which output is the root layout responsible for providing?

Layouts Hard
A. The <html> and <body> elements around its children
B. A <div id="root"> element and a hydration script
C. A <template> element and a client-side router outlet
D. A <main> element and a route-specific <head> element

58 A Client Component handles a successful form interaction and must navigate programmatically to /account without a full document reload. Which API is appropriate?

Navigation Hard
A. useRouter from next/router, followed by router.reload("/account")
B. useRouter from next/navigation, followed by router.push("/account")
C. redirect inside the click handler after marking it async
D. window.location.replace("/account") as the standard router API

59 A page renders <Link href="/reports">Reports</Link>, but /reports has a slow server-rendered subtree. Which statement best captures why navigation may still feel faster than using a plain <a> element?

Navigation Hard
A. Link converts every destination into a fully static HTML document
B. Link may prefetch route data and performs client-side transitions
C. Link bypasses all server rendering after the first application request
D. Link stores the destination's database records in browser local storage

60 A route segment contains page.tsx, loading.tsx, and error.tsx. The page suspends while fetching and later throws during rendering. Which behavior matches the App Router's segment boundaries?

Error and Loading UI Hard
A. error.tsx is ignored whenever the same segment also defines loading.tsx
B. loading.tsx can provide fallback UI, then error.tsx can handle the failure
C. error.tsx renders first, then loading.tsx replaces it after the failure
D. loading.tsx handles both pending work and thrown rendering errors permanently