wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Object-oriented programming final exam

Total questions: 50

Worksheet time: 27mins

Name
Class
Date
1.

What does OOP stands for?

a)

Out of place

b)

Objective Oriented Programming

c)

Object Oriented Programming

d)

Objects Orienting Program

2.

A class is a(n):

a)
  • Instance of an object

b)
  • Blueprint for creating objects

c)
  • Data type

d)
  • Function

3.

An object is a(n):

a)
  • Instance of a class

b)
  • Blueprint for creating classes

c)
  • Data type

d)
  • Function

4.

Properties are:

a)
  • Actions that an object can perform

b)
  • Characteristics of an object

c)
  • Data types

d)
  • Functions

5.

Methods are:

a)
  • Actions that an object can perform

b)
  • Characteristics of an object

c)
  • Data types

d)
  • Functions

6.

A constructor is:

a)
  • A special method that initializes an object

b)
  • A method that returns a value

c)
  • A property of a class

d)
  • A data type

7.

When is a constructor called?

a)
  • When a class is defined

b)
  • When a class is referenced

c)
  • When an object of the class is created

d)
  • When a method of the class is called

8.

Inheritance is:

a)
  • The concept of creating objects

b)
  • The process of creating a new class from an existing class

c)

The ability of a class to inherit properties and methods from another class

d)
  • The process of defining a class

9.

What is the base class in inheritance?

a)
  • The class that inherits properties and methods

b)
  • The class from which properties and methods are inherited

c)
  • The class that is created

d)
  • The class that is destroyed

10.

Abstraction is

a)
  • The process of defining a class

b)
  • The concept of inheritance

c)
  • The process of creating objects

d)
  • The process of hiding unnecessary details

11.

Which of the following is an example of abstraction?

a)

A car's driver

b)
  • A car's engine

c)
  • A car's steering wheel

d)
  • A car's navigation system

12.

Encapsulation is

a)
  • The process of hiding data and methods within a class

b)
  • The concept of inheritance

c)
  • The process of creating objects

d)
  • The process of defining a class

13.

Why is encapsulation important?

a)
  • It makes code more readable

b)
  • It makes code more maintainable

c)
  • It makes code more secure

d)
  • All of the choices

14.

An object is created using the keyword:

a)
  • object

b)
  • new

c)
  • class

d)
  • create

15.

Which access modifier allows a member to be accessed only within its own class?

a)
  • public

b)
  • private

c)
  • protected

d)
  • D. internal

16.

Which access modifier allows a member to be accessed by any class within the same assembly?

a)
  • public

b)
  • private

c)
  • protected

d)
  • internal

17.

Which access modifier allows a member to be accessed anywhere in the project?

a)
  • public

b)
  • private

c)
  • protected

d)
  • internal

18.

When are parameters defined?

a)
  • When a method is called

b)
  • When a method is declared

c)
  • When a variable is declared

d)
  • When a data type is defined

19.

When are arguments passed?

a)

When a method is declared

b)

When a method is called

c)

When a variable is declared

d)

When a data type is defined

20.

5 % 17 = ?

a)

5

b)

17

c)

2

d)

3

21.
Which of the following is an internet protocol?
a)
HTTP
b)
HTML
c)
CSS
d)
UTP
22.

What type of language is PHP

a)

Client Side

b)

Server Side

c)

Browser Side

d)

Web Side

23.

PHP is executed on

a)

The Server

b)

The Browser

c)

The Website

d)

The Machine

24.

We store small snippets of information inside what?

a)

Functions

b)

Loops

c)

If Statements

d)

Variables

25.

We create re-usable code blocks by placing them inside?

a)

Variables

b)

Parameters

c)

Code Blocks

d)

Functions

26.

Sometimes we only want certain code to execute if a condition is true. How do we test for that?

a)

Loop

b)

If Statement

c)

Integer

d)

Variable

27.

$colours = array("black, blue, Red, Green") - How do I access "Red" ?

a)

$colours[0];

b)

$colours[2];

c)

$colours[1]

d)

$colours[3];

28.

How do I print out the values of the variable "name" ?

a)

$name;

b)

include $name;

c)

echo $name;

d)

echo $name

29.

function sayMyName(name) {} ; - How do I call tat function

a)

sayMyname();

b)

$sayMyName;

c)

$sayMyName();

d)

sayMyName("John")';

30.

What type of variable is this: $isMale = false;

a)

Integer

b)

Boolean

c)

String

d)

char

31.

$a = 4 ; $b = 6; $c = $a + $b; What is the value of variable "c" ?

a)

6

b)

8

c)

10

d)

None

32.

Which tag is used for php

a)

<?php

?>

b)

<style>

c)

<php ?>

d)

<php

/php>

33.

<?php

function add()

{

global $a=10;

echo $a;

}

add();

$a+=10;

?>

Output is

a)

10

b)

15

c)

20

d)

30

34.

Which of the following is NOT a valid way to start a PHP code block?

a)

<?php

b)

<?=

c)

<!--

d)

<?

35.

Create a variable in php assign with the

a)

String

b)

const

c)

let

d)

$

36.

Write a correct syntax to include a file named "footer.php".

a)

include ("footer.php");

b)

import("footer.php");

c)

required("footer.php");

d)

export("footer.php");

37.

PHP stands for

a)

Hypertext processor

b)

Homepage processor

c)

Hypertext preprocessor

38.

_______ is a concatenation operator in php

a)

+ (plus)

b)

+=

c)

. (dot)

39.

PHP is a case sensitive

a)

TRUE

b)

FALSE

40.

PHP is a ............

a)

Open Source Language

b)

Widely Used Language

c)

Server side scripting language

d)

All of the above

41.

Which of the following symbol is used to add multiple line comments in PHP ?

a)

//

b)

/* */

c)

{{ }}

d)

{/ \}

42.

Which of the below symbols is a newline character?

a)

<br>

b)

\n

c)

/n

d)

\r

43.

The 2 basic ways to get output in PHP are __________.

a)

echo and cout

b)

echo and scan

c)

echo and print

44.

The default file extension for PHP files is __________.

a)

.html

b)

.php

c)

.css

d)

.java

45.

Where is your PHP project file located?

a)

C:\xampp\htdocs\

b)

C:\xampp\project\

c)

D:\xampp\htdocs\

46.

PHP Scripts are executed using

a)

XAMPP

b)

JAVA

c)

EDITOR

d)

NONE

47.

Choose the equivalent of the statement : $sub -= $sub.

a)

$sub = $sub - 1

b)

$sub = $sub - $sub

c)

$sub = $sub - $sub -1

d)

$sub = - $sub

48.

HTML

page can be access using _______ protocol.

a)

HTTP

b)

FTP

c)

SMTP

d)

POP

49.

Why

should we use functions?

a)

Reusability

b)

Easier

error detection

c)

Easily

maintained

d)

All of

the above

50.

Which of the following is not a component of CRUD?

a)

Create

b)

Read

c)

Update

d)

Drop