wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz Trivia

Total questions: 50

Worksheet time: 29mins

Name
Class
Date
1.

In object-oriented programming, what is the purpose of inheritance?

a)

Combine multiple classes into one

b)

Create a blueprint for objects and allow reuse of code

c)

Limit access to class members

d)

Implement polymorphism

2.

What does the forEach() method do in JavaScript?

a)

Adds a new element to the end of an array

b)

Removes the first element from an array

c)

Executes a provided function once for each array element

d)

Sorts the elements of an array

3.

What does the `print()` function do in Python?

a)

Take user input

b)

Print information to the console

c)

Perform mathematical operations

d)

Define a variable

4.

What is the purpose of the `try` and `except` blocks in Python?

a)

Create a loop

b)

Handle exceptions

c)

Define a function

d)

Open a file

5.

Which method is used to add an element to the end of a list in Python?

a)

append()

b)

insert()

c)

extend()

d)

add()

6.

What is the result of the expression `5 / 2` in Python?

a)

2.5

b)

2

c)

2.0

d)

3

7.

What does the `with` statement do in Python?

a)

Create a new instance of a class

b)

Open a file and automatically close it when done

c)

Define a context manager

d)

Indicate the end of a block of code

8.

Which of the following is a correct way to declare a variable in Python?

a)

variable x = 5;

b)

int x = 5;

c)

x = 5;

d)

var x = 5;

9.

What is the purpose of the `__init__` method in a Python class?

a)

Initialize a variable with a default value

b)

Create an instance of the class

c)

Define a static method

d)

Override a parent class method

10.

How do you declare a constant in PHP?

a)

define_constant()

b)

const()

c)

define()

d)

set_constant()

11.

What does CSS stand for?

a)

Computer Style Sheets

b)

Creative Style Sheets

c)

Cascading Style Sheets

d)

Colorful Style Sheets

12.

What does HTML stand for?

a)

Hyper Transfer Markup Language

b)

Hyper Text Markup Language

c)

Hyperlinks and Text Markup Language

d)

High Tech Markup Language

13.

Which keyword is used to declare variables in JavaScript?

a)

var

b)

int

c)

string

d)

let

14.

What does the CSS property "display: none;" do?

a)

Hides the element

b)

Changes the display style to block

c)

Displays the element as inline

d)

Removes the padding of the element

15.

Which HTML tag is used for creating an unordered list?

a)

  • <ul>

b)

  1. <ol>

c)

  • <li>

d)

<list>

16.

How do you concatenate two strings in PHP?

a)

using the . operator

b)

using the + operator

c)

using the & operator

d)

using the : operator

17.

What is the correct HTML tag for inserting a line break?

a)

br

b)

h1

c)

b

d)

u

18.

What is the purpose of the `for` loop in Python?

a)

Execute a block of code while a condition is true

b)

Iterate over a sequence of elements

c)

Define a function

d)

Handle exceptions

19.

What is the correct HTML for creating a hyperlink to an external website?

20.

Which HTML tag is used to define a table row?

a)

<table-row>

b)

<row>

c)

<tr>

d)

<tablerow>

21.

Which tag is used to define the header of a section or document in HTML5?

a)

<head>

b)

<h1>

c)

<header>

d)

<section>

22.

What is JavaScript primarily used for?

a)

Server-side programming

b)

Styling web pages

c)

Adding interactivity to web pages

d)

Creating databases

23.

How do you start a session in PHP?

a)

session_start()

b)

start_session()

c)

begin_session()

d)

init_session()

24.

Which CSS property is used to change the background color of an element?

a)

background-color

b)

color

c)

bg-color

d)

bgcolor

25.

What does the `isNaN()` function do in JavaScript?

a)

Checks if a value is a number

b)

Converts a string to a number

c)

Checks if a value is not a number

d)

Returns the square root of a number

26.

What does the declaration do?

a)

Defines the document type and version of HTML

b)

Creates a new HTML document

c)

Specifies the document's background color

d)

Declares the document as public or private

27.

What is the purpose of the `lambda` function in Python?

a)

Define a multiline function

b)

Create anonymous functions

c)

Access the global scope

d)

Implement decorators

28.

Which method is used to add a new element to the end of an array in JavaScript?

a)

append()

b)

push()

c)

add()

d)

insert()

29.

Which CSS property is used to change the text color of an element?

a)

font-color

b)

text-color

c)

color (Correct)

d)

font-style

30.

What does the `typeof` operator do in JavaScript?

a)

Checks if a variable is defined

b)

Returns the data type of a variable

c)

Converts a string to uppercase

d)

Checks if two variables are equal

31.

Which tag is used to define a hyperlink in HTML?

a)

<link>

b)

<a>

c)

<href>

d)

<hyper>

32.

Which function is used to output data in PHP?

a)

print()

b)

echo()

c)

display()

d)

output()

33.

What does the CSS property "float" do?

a)

Makes an element float above other elements

b)

Floats an element to the left or right of its container

c)

Adds a shadow effect to an element

d)

Changes the font size of an element

34.

What is the purpose of the <img> tag in HTML?

a)

Insert an image

b)

Insert a hyperlink

c)

Insert a paragraph

d)

Insert a table

35.

Which of the following is used to comment multiple lines in PHP?

a)

/* */

b)

//

c)

#

d)

[]

36.

Which CSS property is used to control the spacing between lines of text?

a)

line-height

b)

spacing

c)

text-spacing

d)

line-spacing

37.

What does DOM stand for in JavaScript?

a)

Document Object Model

b)

Data Object Model

c)

Document Order Model

d)

Display Object Model

38.

Which PHP function is used to redirect the user to another page?

a)

header()

b)

redirect()

c)

location()

d)

go()

39.

What does the `$_GET` superglobal variable in PHP do?

a)

Retrieves data sent in the request body

b)

Retrieves data sent via URL parameters

c)

Retrieves data from a form with the POST method

d)

Retrieves data from a file upload

40.

Which CSS property is used to make text italic?

a)

text-decoration

b)

font-style

c)

text-style

d)

italicize

41.

Which of the following is NOT a valid data type in JavaScript?

a)

boolean

b)

float

c)

string

d)

object

42.

Which keyword is used to exit a loop in JavaScript?

a)

break

b)

stop

c)

exit

d)

end

43.

Which CSS property is used to set the width of an element?

a)

size

b)

width

c)

length

d)

set-width

44.

What does PHP stand for?

a)

Personal Home Page

b)

Hypertext Preprocessor

c)

Preprocessed Hypertext Page

d)

Private Home Page

45.

What is the correct HTML for creating a checkbox input field?

a)

<input type="check">

b)

<input type="checkbox"> 

c)

<checkbox>

d)

<input style="checkbox">

46.

What is the purpose of the `===` operator in JavaScript?

a)

Assignment

b)

Equality comparison (strict equality)

c)

Type conversion

d)

Logical OR operation

47.

How can you include an external CSS file in an HTML document?

a)

<import css="style.css">

b)

<link rel="stylesheet" href="style.css"> 

c)

<style src="style.css">

d)

<css src="style.css">

48.

Which of the following tags is used to start and end a PHP code block?

a)

<?php ?>

b)

<% %>

c)

<?= ?>

d)

<? ?>

49.

Which PHP function is used to connect to a MySQL database?

a)

connect()

b)

db_connect()

c)

mysql_connect()

d)

mysqli_connect()

50.

What is the output of `console.log(10 + "20")` in JavaScript?

a)

30

b)

"1020"

c)

1020

d)

Error