0% found this document useful (0 votes)
12 views105 pages

Hssc-2 (Pets CPTR MCQS)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views105 pages

Hssc-2 (Pets CPTR MCQS)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 105

APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC

School: Army Public School & College (Girls) Psc Subject: Cptr Science
Developer: Ms Humera Wadood Cl / lvl: HSSC – II Title of the Chapter / Concept: Ch # 1: Operating System

Option Ref Ref Bloom’s


Ser MCQ Ans
A B C D Pg Book domain

Which of the following


Application
1. is NOT a type of Mobile OS Desktop OS Server OS D 9 NBF Knowledge
software
operating system?

Which of the following


2. describes the creation New Old Ready Waiting A 18 NBF Understanding

of a process?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

In an office, a
computer is
connected to a printer,
which function of the
operating system File Input/output Process Network
3. B 17 NBF Application
manages the Management Management Management Management
communication
between the computer
and the printer to print
documents?
Which of the following Only one The system is
is a benefit of using a Multiple users can It is faster than
person can use more secure
4. share resources like a single-user B 14 NBF Knowledge
multi-user operating the computer at than a single-
system? files and printers system
a time user system

What function does a Manage a Allow computers to


Establishing an
network operating single share resources on For playing
5. internet B 17 NBF Knowledge
system perform? computer a network video games
connection
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

Which of the following


6. DOS command is RD DEL Rmdir DELETE FILES B 10 NBF Knowledge
used to delete files?

Which operating
system is open-source D 9 NBF Knowledge
7. Windows 10 macOS iOS Linux
and free to use among
these?
When a user saves a
document, which
function of the
operating system Task Input/output Protection
8. File Management B 16 NBF Application
manages the storage Scheduling Management System
of the file and keeps
track of its location for
future retrieval?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

Which of the following


files can the Windows
cmd.exe IOsys.exe BIOS.exe Time.exe
9. operating system use A 17 NBF Knowledge
as a command
interpreter?

In which of the Time Sharing Batch Processing Quick


Real Time OS
10. following OS is OS OS Response OS D 10 NBF Understanding

response time crucial?

What is the purpose of Manage tasks Monitor system


Set up network Install new
the 'Task Manager' in and performance and B 24 KPK Understanding
11. connections software
Windows OS? appointments manage processes

What is thread in A light weight


Process A system call A hardware
12. context of an process B 23 KPK Knowledge
component
operating system?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

In multiprocessing,
what is the term used
to describe the
Multi- Time-sharing Parallel Batch
13. simultaneous C 13 KPK Understanding
programming processing processing
execution of two or
more processes on
multiple processors?

A company is
developing a new
smartphone. What
Windows Mac OS Linux Android
14. type of operating D 16 KPK Understanding
system is typically
used in modern
smartphones?
What major benefit
Improved hardware
does
Increased user utilization through Better privacy
multiprogramming Less electricity
15. interface overlapped I/O and and data B 13 NBF Understanding
provide in an usage
responsiveness CPU processing security
operating system?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

Which operating
system is commonly
found in embedded
Windows Embedded
systems like digital C 16 KPK Understanding
16. Embedded Mac OS Linux Android
cameras, smart TVs,
and microwave
ovens?

Memory space, User interface, Operating


What are the key Network card,
code, data, keyboard, mouse, system kernel, A 19 NBF Understanding
17. components of a printer, storage
execution state monitor drivers, system
process? devices
libraries

What does an To equitably To control the


To prioritize
operating system's distribute CPU To avoid using order in which
system
18. process management time among more RAM than is processes A 15 NBF Knowledge
processes over
function accomplish? various available access I/O
user processes
processes devices
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

When a process is
waiting to be assigned
19. Ready Running New Blocked A 18 NBF Knowledge
to the processor, what
is itsl state?

To indicate that To show that To represent a


What is the purpose of To mark a process
the process is the process is in process that is
20. the terminated state in that has finished B 18 NBF Knowledge
waiting for an a state of waiting for CPU
a process lifecycle? execution
event suspension time

When a process is
waiting for a resource
21. that is being used by Ready Running Blocked Suspended C 18 NBF Understanding
another process, what
state is it in?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

Which type of
operating system is
most suitable for a
computer used in a
Real-time Multi-user Mobile
scientific research Network Operating
22. Operating Operating Operating C 14 NBF Application
laboratory where System
System System System
multiple users need to
run complex
simulations
simultaneously?

Which unit of
execution is run in
23. Program Thread Process Data B 19 NBF Knowledge
shared memory
space?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

What is the main goal To provide To prevent To ensure


of memory maximum applications from efficient and To speed up
management function available RAM accessing each optimal the boot
24. C 17 KPK Understanding
in an operating for other's memory utilization of process of the
system? applications. space. memory computer
resources

Windows was
25. developed in the year: mid 1970s mid 1980s mid 1990s mid 1960s B 11 NBF Knowledge

In which of the
following operating
system executes more
than one process Multitasking Multiprogramming Multithreading Multiprocessing
26. D 20 NBF Understanding
simultaneously on
multiprocessor
system?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

You are setting up a


network for a large
organization with
multiple users
accessing shared Real-time Single-user Mobile
Network operating
27. resources. Which type operating operating operating B 17 NBF Application
system
of operating system system system system
would be best suited
for managing user
permissions and
access control?
A supercomputer
used for scientific
simulations and data Multi-user Network Parallel
Real-time Operating
28. analysis requires an Operating Operating Operating D 14 NBF Application
System
operating system that System System System
can efficiently manage
parallel processing.
Which type of
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

Which of the following


29. operating system runs Batch OS Distributed OS Real-time OS Network OS D 17 NBF Understanding

on the server?

In multiprogramming
one program is in
First program is Second program is Third program
CPU at a time and A 13 NBF Understanding
30. completed or completed or is completed or Only A and C
other program will
blocked. blocked. blocked.
have to wait until?

Which operating
system is designed to Batch
Real-time Time Sharing
execute a specific set Processing Distributed
31. Operating Operating A 13 NBF Knowledge
of jobs repeatedly Operating Operating System
System System
without human System
intervention?

An operating system
32. developed by Apple Windows Linux Unix Mac OS D 11 NBF Knowledge

Inc is known as:


Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

A module of an
operating system
responsible for the
coordination and Command Network
33. File Manage Memory Manager B 17 KPK Understanding
movement of data Interpreter Manager
between registers,
cache ,RAM and disk
storage is known as:

Each processor
Which of the following All processors
Only one may execute a Processors are
is a characteristic of execute the same
34. processor is different not allowed to C 13 KPK Understanding
multiprocessing program
used program share data
systems? simultaneously
independently
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

In multiprogramming,
what is the term used
to describe the
Batch
35. process of switching Time-sharing Context switching Multi-tasking B 10 KPK Knowledge
processing
between different
programs to keep the
CPU busy?
APSACS PREP FOR ENTRY TESTS (PETS) PROGM – HSSC

School: APSAC for boys Multan Subject: Computer Sci

Developer: Mr. Tausif Mumtaz Cl / Lvl : XII Title of the chapter / Concept : SDLC

Options Ref Ref Bloom’s


Ser MCQ Ans
A B C D Pg Book domain

SDLC is a
Hardware Software Chemical Mechanical
1. process that is B 25 NBF understanding
Engineering Engineering Engineering Engineering
used in the field
The term
2. “system” is the Greek French English German A 36 NBF understanding
word of
It delivers quality
software that Astera Contour
3. Agile development SDLC C 25 NBF Analysis
meets the system Software Software
requirement
Which one is
4. NOT for sponsor Planner Developer Salesman D 26 NBF understanding
stakeholders?
Which team is Designing
Project Analysis
5. responsible for Coding team management A 26 NBF Understanding
management team team
identifying the team
stakeholder for
their requirement,
expectation, and
a successful
project?
SDLC have
6. Nine Ten Eleven Twelve B 26 NBF Understanding
phases
In which phase of
SDLC the
requirement are
Design
7. documented and Planning Phase Defining Phase Testing Phase C 27 NBF Analysis
Phase
approved from
customer or
company.
Which phase of
SDLC is most
suitable for the
Planning
8. designing and Testing Phase Design Phase Defining Phase D 27 NBF Analysis
Phase
development of
product
requirement?
To meet the Design
9. Planning Phase Defining Phase Testing Phase A 27 NBF Understanding
objective of the Phase
project is
determined SDLC
phase is
considered
Which phase is
chosen for the
estimation of
resources such Testing
10. Defining Phase Planning Phase Coding Phase C 27 NBF Analysis
as personnel and Phase
costs with
concept of the
new product?
Which phase of
SDLC is if all the
information is
Defining
11. analyzed to see Planning Phase Testing Phase Coding Phase A 27 NBF Analysis
Phase
for an alternative
solution to create
the new product?
SDLC ____
Phase is used to Testing Feasibility
12. Defining Phase Planning Phase D 27 NBF Understanding
access the Phase phase
strengths and
weaknesses of
the proposed
system.
Which of the
following is used
to improve a
project and
Planning
13. achieve desire Testing Phase Feasibility phase Defining Phase C 27 NBF Understanding
Phase
result by
presenting
directions of
activities?
Feasibility studies
depend primarily
Proposed Approved
14. on the areas in Analyzed projects Desired projects A 27 NBF Understanding
projects projects
which _________
are Implemented.
Feasibility study
*is one of the
15. important steps in Four Five Six Seven B 27 NBF Understanding
SDLC divided
into form.
Which of the
following is NOT Economic Operational Non-Technical Schedule
16. C 27 NBF Understanding
taken as a type of Feasibility Feasibility Feasibility Feasibility
feasibility study?
During the
analysis phase
17. the project team End user Customer Developer Designer A 28 NBF Analysis
determines the
requirements of
In which phase
the end user
requirements
Testing Feasibility
18. determine with Defining Phase Analysis Phase C 28 NBF Understanding
Phase phase
the assistance of
client focus
groups.
In analysis phase
which team
decide whether
Designing
19. the project should Project team Coding team Testing team A 28 NBF Understanding
team
go ahead with
available
resources or not.
Which of the
following team
asks some
20. specific queries Coding team Testing team Designing team Project team D 28 NBF Understanding
during the
analysis of a
project.
Which one is the
process of
determining user Requirement Software Hardware Network
21. A 28 NBF Application
expectations for a Engineering Engineering Engineering Engineering
new or modified
system?
___________ is a
set of activities
used to identify
and communicate
Software Hardware Requirement Network
22. the purpose of a C 28 NBF Application
Engineering Engineering Engineering Engineering
software system
and frame work in
which it will be
used.
Requirement
Engineering
23. Two Three Four Five B 28 NBF Understanding
consists of
number of steps
Which one is
NOT considered Requirement Requirement Requirement Requirement
24. D 28 NBF Understanding
in Requirement gathering validation management testing
Engineering
The primarily part
of any software /
Requirement Requirement Requirement Requirement
25. system C 28 NBF Understanding
validation management gathering testing
development
process is
Which step is
most suitable for
meeting with Requirement Requirement Requirement Requirement
26. D 28 NBF Understanding
customers and testing validation management gathering
market
requirements
How many types
exist in
27. Two Three Four Five A 28 NBF Understanding
Requirement
gathering?
Which of the
following
requirements is
suitable to specify
Requirement Functional Requirement Non-Functional
28. the software B 28 NBF Understanding
validation requirement gathering requirement
functionality to
enable user to
accomplish their
tasks?
Which type of
requirements
specify criteria for Functional Requirement Non-Functional Requirement
29. C 28 NBF Understanding
the judgment of requirement gathering requirement validation
the operations of
a system?
____________ is
concerned with
examining the
requirements to Requirement Requirement Requirement Requirement
30. B 28 NBF Analysis
certify that they testing validation management gathering
meet the
intentions of the
stakeholders.
In
______________
the requirements
elicited are
Requirement Requirement Requirement Requirement
31. reviewed to D 29 NBF Analysis
management gathering testing validation
check that
requirements are
complete and
accurate.
Which of the
following
requirements
performed to
Requirement Requirement Requirement Requirement
32. ensure that the C 29 NBF Analysis
gathering testing management validation
software
continues to meet
the expectations
of users?
Which
requirements Requirement Requirement Requirement Requirement
33. C 29 NBF Analysis
needs to gather gathering testing management validation
new requirements
from sources of
change?
“Architectural”
phase of a Coding Analysis
34. Design phase Testing Phase A 29 NBF Analysis
system design Phase Phase
represented for
Which team
determines the
most logical
Designing
35. design and Project team Coding team Testing team A 29 NBF Understanding
team
structures for
data flow and
storage?
How many
different
structures a
36. Two Three Four Five A 29 NBF Understanding
design phase
normally
consists?
Which technique
is a specific
37. Design Layout Algorithm Flowchart C 29 NBF Understanding
procedure for
carrying out the
solution of a
problem?
A _______ is a
type of diagram
38. that represents Algorithm Flowchart Design Layout B 29 NBF Understanding
an algorithm or a
process.
In which of the
following
39. Analyzing Designing Documenting Coding D 29 NBF Application
flowchart is NOT
used.
Which symbol is
40. used for I/O Parallelogram Rectangle Diamond Terminal A 30 NBF Understanding
operation?
Which symbol is
41. used for Process Parallelogram Rectangle Diamond Terminal B 30 NBF Understanding
operation?
Which symbol is
42. used for condition Parallelogram Rectangle Diamond Terminal C 30 NBF Understanding
operation?
A diamond
43. Two Three Four Five A 30 NBF Understanding
symbol has exit
During the
construction
phase developers Testing
44. Defining Phase Analysis Phase Design phase D 31 NBF Analysis
execute the plans Phase
laid out in
____________.
In which phase
test data is
prepared and
Analysis construction
45. processed as Testing Phase Design phase C 31 NBF Analysis
Phase phase
many times as
necessary to
refine the code.
The actual user
interface is
construction
46. designed by Analysis Phase Design phase Coding Phase D 31 NBF Analysis
phase
developers in
_______
Coding is also Computer Computer Software Software
47. A 31 NBF Understanding
called programming software package program
In which phase all
Coding Verification
48. aspects of the construction phase Testing Phase D 31 NBF Understanding
Phase Phase
system are tested
for functionality
and performance.
The execution of
a programming
49. Debugging Testing Verification Validation B 31 NBF Understanding
modules to find
errors is called
To evaluate the
attribute or
50. capability of a Coding Verification Validation Testing D 31 NBF Understanding
program is the
purpose of
It is the process
of checking the
items for
consistency by
51. Testing/Verification Verification Testing/Validation Validation A 31 NBF Analysis
evaluating the
results against
prespecified
requirements.
It is set of
Software Software Software
52. activities that are Software Coding B 32 NBF Understanding
implementation deployment Testing
used to make the
software
available for use.
Deployment is
53. SDLC phase also Implementation Conversion Maintenance Activation A 32 NBF Understanding
known as
How many
techniques are
54. Three Four Five Six B 32 NBF Understanding
commonly used
for deployment
In which
technique of
deployment, the
Phased Direct Pilot
55. old system Parallel method C 32 NBF Analysis
method implementation implementation
completely
replaced by new
system.
Which of the
following method
encountered the
Phased Direct Pilot
56. problems of the Parallel method A 32 NBF Analysis
method implementation implementation
new system and
corrected without
the loss of data.
In which method
of deployment,
Phased Direct Pilot
57. the old system is Parallel method B 32 NBF Analysis
method implementation implementation
progressively
discarded.
Which one of the
following
methods of
implementation is
Phased Direct Pilot
58. used for the new Parallel method D 33 NBF Analysis
method implementation implementation
system
installation for a
small number of
users.
In all phases of
SDLC which one Testing Maintenance Deployment
59. Coding Phase C 33 NBF Understanding
is ongoing Phase Phase Phase
process.
Which one is
NOT suitable for
60. Repairing Replacement Modification Enhancement B 33 NBF Understanding
maintenance
phase in SDLC?
SDLC activities
are performed by
61. different groups Personnel End user Coder Analyst A 33 NBF Understanding
of people and
individuals ____.
Personnel are
professional
62. Four Five Six Seven C 33 NBF Understanding
having
classification
Which one of the
personnel provide
consistency of
success of the System Management
63. Project Manager Programmer D 34 NBF Understanding
software with Analyst Team
regard to Time,
Cost and Quality
objectives.
A ______ is a
professional
System Management
64. responsible for Project Manager Programmer A 34 NBF Understanding
Analyst Team
planning,
execution and
closing of any
project.
___________
has expertise in a
variety of
programming
System Management
65. languages, Project Manager Programmer B 35 NBF Understanding
Analyst Team
operating system
and computer
hardware
platform.
Which of the
following
personnel
preparing graphs,
table and System Management
66. Project Manager Programmer C 35 NBF Understanding
analytical data Analyst Team
display which
shows the
progress of
program.
Which of the System Management
67. Software Tester Programmer A 35 NBF Understanding
following Analyst Team
personnel having
specialty in
testing program
using different
testing
techniques
Which one are
the real
evaluators of
System
68. software product Software Tester Programmer Customers D 36 NBF Understanding
Analyst
by using it and
identify its merits
and demerits.
Which one of the
following interact
with designer to System Management
69. Project Manager Programmer B 35 NBF Understanding
understand Analyst Team
software
limitation.
Which one of the
System Management
70. following Project Manager Programmer D 34 NBF Understanding
Analyst Team
personnel reduce
risk associated
with the project.
A customer is an
individual or an
organization that
System
71. is a current or Software Tester Programmer Customers D 36 NBF Understanding
Analyst
potential buyer or
user of the
software product.
APSACS 'PREP FOR ENTRY TESTS (PETS) PROGM – HSSC
Subject: Computer Science
Developer: Ms Bushra Soomro Cl / Ivl : HSSC II Title of the Chapter I Concept: CH#3- Object Oriented Programming in C++

Option
An Ref Ref Bloom's
Ser MCQ
s Pg Book domain
A B C D
What is more important in executing a
Programming
1. set of instructions in a computer Sequence Repetition Control B 63 KPB Understanding
logic
program?
A type of language in which
Machine Assembly High level Natural
2. instructions consist of binary form (0’s A 41 NBF Knowledge
language language language language
and 1’s ) is called:
The process of converting source code Understanding
3. into object code is known as: Compilation Debugging Linking Information A 134 PTB

A statement that starts with a # symbol Preprocess Understanding


4. is called Data type Keyword Comment D 41 NBF
or directive

In C++ Header files contain: Standard library


5. Formulas Comments Keywords A 62 BTB Knowledge
functions
The output of the compiler is called: Object
6. Library code Source code Linked code D 41 NBF Understanding
code
Which of the following header file
contains information about common
7. iostream.h cmath.h conio.h cale.h B 42 NBF Application
mathematical functions such as
finding the square root of a number?
The name of header file is written in
8. between: [] () <> << >> C 41 NBF Application
In C++ which of the following is the
‘# This is the ‘//This is the ‘/*This is the ‘<This is the
9. correct syntax for a single line B 160 PTB Evaluate
Comment’ Comment’ Comment*/’ Comment’>’
comment?
The extension of C++ source program
10. is: .h .cpp .obj .exe B 135 PTB Understanding

Which term in commonly used to refer Shut


11. to software or program errors ? Bug Crash Short Circuit A 140 PTB Knowledge
Down

Dividing a number by zero (e.g.5/0 ) is Runtime Syntax


12. an example of: Compiler Error Logical Error B 141 PTB Understanding
Error Error
The basic structure of C++ program Preprocessor main { } Program 42-
13. consists of: All D NBF Understanding
Directive function body 43

Which programming structure


14. executes program statements in order Relation Decision Sequence Repetition C 49 KPK Knowledge
?
Which header file lets us work with #include #include #include #include
15. input and output objects? B 137 PTB Knowledge
<inputstr> <iostream> <iosstring> <stream>

Operator is used for input stream is:


16. “>>” “<<” “>” “<” A 52 KPK Understanding

In C++ which of the following is used both A and


17. for comments? /* comment */ // comment */ // comment D 160 PTB Understanding
C

Which of the following approach is


18. used by C++? Left-right Right-left Bottom-up Top-down C 146 PTB Knowledge

Who calls to the function main()? operating


19. kernel CPU ALU B 42 NBF Understanding
system
When a variable assigned a number
20. that is too large for its data types, it is Overflow Underflow Top flow Excess A 149 PTB Analysis
called
What is the name for a word that has
21. fixed meaning and cannot be changed Keyword Comment Token Operator A 149 PTB Knowledge
by user?
if, void, break, while, case and char are Reserved Compiler
22. examples of: Comments Identifiers B 149 PTB Understanding
Words Directives

The exponential notation consists of: Both


23. Mantissa Exponent Rang D 67 KPB Knowledge
A and B

In C++ language char ch = ‘3’ A Numeric A Character


24. represents: A digit A Word C 82 KPB Analysis
constant Constant

In C++ which of the following is not


25. valid DATA type? float bool char* long long C 152 PTB Understanding

What is correct way to declare a


26. variable in C++? var=x; x=var; int x; x= int; C 148 PTB Understanding

A process of assigning initial value to


27 a variable at the time of declaration is Assigning Initializing Naming Executing A 62 KPB Knowledge
called?
Which of the following is a valid way to Constant
28 declare a constant variable in C++? int const x=5 int x=5; const const int x=5 B 47 NBF Understanding
x=5

What happens when the result of a


29 calculation exceeds the capacity of System error Logic error Syntax error Overflow D 150 PTB Understanding
data type ?

In C++, the maximum length of a


30. 8 16 32 64 C 46 NBF Knowledge
variable is:
Variable names cannot begin with: Upper-case Lower-case
31. Number Underscore A 45 NBF Knowledge
letter letter

Which of the following is an invalid


32. variable name? _cust_num Jan-09 dayOfWeek 2dGraph D 132 PTB Understanding

In C++, numeric data types can be Arithmetic


Integer and Single and Numbers and
33. divided into two general categories and A 45 KPK Knowledge
floating point double characters
called: Algebra
A method to convert the data type of a Variable Type 47-
34. value Is called: Type casting Value casting B NBF Application
changing changing 48

The number of bytes used by double


35. data type in C++ is: 2 8 12 16 B 152 PTB Understanding

Which of the following constant const float const float const


36 definitions is correct? PRICE = const int COST = MY_HEIGH B 47 NBF Understanding
3,500; $700.0: T=60/12:

In C++, character constants are written Double quotes Single quotes Exclamation Pound
37. B 152 PTB Understanding
within: (") (‘) points {!) signs (#

Which of the following data type is


38. int float double bool D 46 NBF Understanding
provided by C++ but not C?

39. The constants are also called? const preprocessor literals variables C 142 PTB Knowledge

How does the constants declare in #define both A and


40. const keyword $define D 47 NBF Application
C++? preprocessor B

A variable that can be used with in the


Global Nominal Ordinal
41. function in which it is declared is Local Variable A 47 NBF Understanding
Variable Variable Variable
called?
A storage
location in
42 A variable is a symbol that represents: A number A string the Nothing C 47 NBF Understanding
computer's
memory

What does this code print on the


43. “FBISE” FBISE fbise “ “ B 137 PTB Analysis
screen? Cout << “ FBISE ";

Which of the following are used to


44. Iterators Punctuators Manipulators Allocators C 54 NBF Understanding
format the data display in CPP?

Ends the Clear the


What does the “endl” manipulator do in Insert a new Skip the next
45. program output B 54 NBF Application
C++? line character input
execution buffer

Predict the output: int x = 786; cout


46. 786*** **786 ***786 ****** C 54 NBF Evaluate
<<setfill(‘*’)<<setw(6)<<x;

What will be the output of 157-


47. 8.859 8 859 0.859 B PTB Analysis
cout<<(int)8.859; 159

In C++, which escape sequence can


48. \a \b \n \t D 52 NBF Application
be used to insert a Tab?

49. In C++, gets stand for ? get std get stream get string get str C 171 PTB Understanding

Which header file includes getche ( )


50. iostream.h cmath.h conio.h cale.h C 42 NBF Application
and getchar ( ) functions?

51. Escape sequences are prefixed with? % \ ““ ? B 169 PTB Understanding


What is the benefit of C++ input and Both Type
Sequence
52. output over C input and output? Type safety Exception safety & A 52 KPK Knowledge
container
Exception
What is the output of this C++ code
{
Compile time
char c='d'; d in the d on the Undefined 42-
53 error (after first C NBF Application
putchar(c) myfile file screen behaviour 43
command)
;
}
<
Which header file is used for < iomanipulator.h <
54. stdiomanip.h < D 52 KPK Knowledge
manipulators? > iomanip.h>
> stdmanip.h>
How many escapes sequence can be
55 2 4 6 Multiple D 51 NBF Understanding
used within format string in C/C++?
Which of the following escape
56. sequence is used for beep in format \a \b \\ \beep B 152 PTB Application
string?
Which of the following escape
57. sequence is used for carriage return? \c \cr \r \\r C 53 KPK Application

Which of the following operator is used Relational Assignment Arithmetic Logical


58. to join two conditions? D 64 NBF Analysis
operator operator operator operator

In C++ language, two conditions can Arithmetic Relational Logical Bitwise Understanding
59. C 89 BTB
be joined by using Operators Operators Operators Operators

156-
60. a + = b is equivalent to: b+=a a=+b a = a+b b= b+a C PTB Application
157

Which of the following returns True if 61-


61. A+B A>=B A=B A!=B D NBF Analysis
A = 25 and B = 35 62
What does the given expression
62. 8 11 13 15 A 64 NBF Application
evaluate to E = 6 + 5 * 4 % 3

What is the output of following code


segment:
{
63 int x=5, y=2; 2&1 2&2 2 & 0.5 2.5 & 0.5 B 153 PTB Evaluate
cout<<x / y<<” &”<< x % y;
return 0;
}
What is the output of following code
segment:
{
58-
64. int x=5, y=2; x+=y;x=52 x+=y;x=25 x+=y;x=6 x+=y;x=7 D NBF Application
59
cout<<x / y<<” &”<< x % y;
return 0;
}
What is the output of following code
segment:
{
Int A, B;
B=10; A=10 A=10 A=11 A=11
65. B 60 NBF Evaluate
A=B++; B=10 B=11 B=10 B=11
cout<<”A=”<<A;
cout<<”B=”<<B;
return 0;
}

The conditional operator is used as an 157-


66. if if - else if – else-if switch B PTB Application
alternative to . 159

For A = 4 and B = 4 which evaluates


67. A!=B A<B A>B A>=B D 153 NBF Evaluate
as true?
If a = 5 and b = 10, what will be the
68. output of the following expression? 15 20 25 50 A 157 PTB Application
a>b? a*b: a+b;
The value of the C++ expression
69. 13 + 21% 4 - 2 is: 0 12 14 16 B 158 PTB Evaluate

What is the output of following code


segment:
{
int x=5, y=6;
70. Resul=8 Result=9 Result=10 Result=11 C 157 PTB Evaluate
Int result = --x+y++;
cout<<”Result”<<result<<endl;
return 0;
}

‘a’ is an integer variable then


71. 2 2 2.5 5 B 155 PTB Evaluate
statement a=5/2; will return a value:

Relational Assignment Modulus Logical


73. The symbol % is called: C 158 PTB Understanding
operator operator operator operator

The expression 10%3 has a value


74. 1 3 9 11 A 58 NBF Evaluate
equal to:

Which of the following relation


75 = != >= == D 156 PTB Understanding
operator represent equal in C++?

Which of the following operators has


76. ! + = == C 158 PTB Understanding
the lowest precedence?

The character EOF if an 42-


77. What is the return value of putchar()? Nothing Both A & B A NBF Application
written error occurs 43
Both are
Variable = expression; which one is None of
78. variable expression evaluated B 65 NBF Analysis
evaluated first? them
equally

The sqrt function is declared in the


79. <ioslib.h> <math.h> <iostream.h> <conio.h> B 43 KPK Application
header file:

top to
In which direction does the left to right right to left bottom to
80. bottom B 65 NBF Analysis
assignment operation will take place? top

Pick out the compound assignment a=a/b a -= 5


81. statement. a=a–5 a=a+5 C PTB 160 Application

What will be the output of the following


C++ code?
#include <iostream>
using namespace std;
int main()
{
int a, b;
a:4 b:7 a:10 b:4 a:4 b:10
82. a = 10; a:4 b:6 A NBF 63 Evaluate
b = 4;
a = b;
b = 7;
cout << "a: " << a;
cout << "\nb: " << b;
return 0;
}
What will be the output of the following
C++ code?
#include <iostream>
83. using namespace std; 2 7 9 14 A NBF 63 Evaluate
int main()
{
int a, b, c;
a = 2;
b = 7;
c = (a > b) ? a : b;
cout << "c: " << c;
return 0;
}
What will be the output of the following
C++ code?

#include <iostream>
using namespace std;
int main() {
84. 1000 11 1010 1001 C PTB 157 Evaluate
int i, j;
j = 10;
i = (j++, j + 100, 999 + j);
cout << i;
return 0;
}
What will be the output of the following
C++ code?

#include <iostream>
using namespace std;
int main()
{
85. 50 60 70 90 A PTB 157 Evaluate
int a = 20, b = 10, c = 15, d = 5;
int e;
e = a + b * c / d;
cout << e << endl;

return 0;
}
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: Army Public School & College (Girls) Psc Subject: Cptr Science
Developer: Ms Humera Wadood Cl / lvl: _HSSC - II__ Title of the Chapter / Concept: Chapter # 4 Control Structures
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain
do {
while for (initialization ;
What is the correct syntax statement; } do { statement; }
1. (condition) condition; update) A 83 NBF Knowledge
for a while loop? while while (condition);
{statement } statement;
(condition);
What happens if the
The program
condition in an if The program
An error is continues to the The program
2. statement is false and enters an C 71 NBF Understanding
generated next statement terminates
there is no else infinite loop
after the if block
statement?

Which of the following is


if {condition} if (condition)
3. the correct syntax for an if condition condition? if: else C 71 NBF Knowledge
then; { /* code */ }
if statement?

To check an
What is the purpose of the To define a To create a additional condition To terminate the
4. C 74 NBF Understanding
else if statement in C++? new variable loop if the preceding if program
condition is false
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain
It moves to It exits the switch
In a switch statement, the next case statement,
It terminates It is not allowed in
5. what is the role of the without transferring control D 77 NBF Knowledge
the program a switch statement
break statement? executing the to the statement
current one following the switch
It leads to fall-
What happens if there is through, and
no break statement in a It generates a It causes a subsequent cases It has no effect on
6. C 77 NBF Understanding
case block in a switch compiler error runtime error are executed until a the program
statement? break or the end of
the switch

In a switch statement, can Only if the case Only if the case


7. multiple case labels have Yes No labels are labels are of B 77 NBF Understanding
the same code block? consecutive different data types

What data type can be


used as the controlling
8. Float Double Char All of the above C 80 NBF Knowledge
expression in a switch
statement?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain
What will the following
C++ code print? All odd numbers
9. 135 24 Nothing A 88 NBF Understanding
for (int i = 1; i <= 5; ++i) from 1 to 5
{ if (i % 2 == 0)
{ continue; } Defines the Specifies the Determines how
What is the role of the Controls the
initial value of condition for the loop counter
10. increment/decrement number of times C 81 NBF Understanding
the loop continuing changes after each
expression in a for loop? the loop executes
counter. the loop iteration.

Consider a while loop with The loop will


The behavior of
the following condition: i < execute once The loop will The loop will not
11. loop is C 83 NBF Understanding
10. What will happen if the and then run endlessly execute at all
unpredictable
initial value of i is 15? terminate

In nested loop, which loop


12. Outer loop Inner loop Both loops Nothing B 89 NBF Understanding
runs faster?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain
Pre-test
Pre-test uses
checks the
loop Pre-test is more Pre-test can lead to
What is the main condition
initialization efficient for short infinite loops, post-
13. difference between pre- before each A 87 NBF Knowledge
variables, loops, post-test for test cannot.
test and post-test loops? iteration, post
post-test long loops
- test checks
doesn't.
after.
The do-while The do-while
What is the advantage of The do-while loop The do-while loop
loop is more loop is easier
14. using a do-while loop works better with always executes at D 87 NBF Knowledge
efficient for to read and
compared to a while loop? user input. least once
small loops. understand
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain
What will be the output of
the following code?
int num = 10;
if (num < 5) Number is
Number is
{ cout << "Number is less greater than Nothing is printed Compile error
15. less than 5 B 73 NBF Understanding
than 5"; } or equal to 5
else
{ cout << "Number is
greater than or equal to
5"; }

Which statement is used


to terminate the entire break continue exit(int) return(int)
16. C 89 NBF Knowledge
program execution
immediately?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

Inside a loop
to skip the
remaining
code in the In functions to skip
Where can the continue Within any Within switch
17. current certain lines of B 87 NBF Knowledge
statement be used? block of code statements
iteration and code
continue with
the next
iteration

Find out the error in the There is no


100 should be
following segment of a semicolon at Equals to operator Variable x should
enclosed in
18. program: the end of mistake not be inside C 71 NBF Understanding
quotations
if (x=100) first line quotation
cout<<”x is 100”;

Which of the following is a


19. valid case statement in case a<5 case ‘ab’ case 3.5 case 3 D 77 NBF Understanding
switch?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain
the body of
A while loop is more the program the number of the terminating
the loop is to
20. appropriate to use than a executes at iteration are known condition occurs D 82 NBF Knowledge
be executed
for loop when: least once in advance unexpectedly
at least once
The number of
21. expressions in for loop 2 3 4 1 B 82 NBF Knowledge
syntax are:

In if statement, test
condition/expression is
22. { } [ ] < > () D 71 NBF Knowledge
written within these
delimiters:

An if statement inside the Conditional Branched if


Switch Nested if statement
23. true block of another if operator statement C 80 NBF Knowledge
statement
statement is called:

Which of the following is


24. also called countered while For do while nested loop B 82 NBF Knowledge
loop?
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain
What is the output of the
following segment of C++
program?
25. Bye Hello Hello…Bye Runtime error A 71 NBF Understanding
if (10>12)
{ cout << “Hello…”; }
cout<< “Bye”;
Detect an error in the
following code: Float value
float a= 1.5; cannot be
switch(a) Variable is passed cout cannot be break is used in
26. B 77 NBF Understanding
{ case 1.5: not correct through used after case 2.5 case 2.5
cout<<”Hello”; break; switch
case 2.5: cout<<
“Bye”; break;}

Each pass through a loop test iteration


27. cycle duration C 81 NBF Knowledge
is called a/an

A special value that is sentinel


control value end value
28. used to terminate a loop is value terminate value B 87 KPK Knowledge
called:
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

the body of
the logical
the loop will
What is wrong with the operator &
be executed the test condition is the test condition is
29. following code: cannot be C 83 NBF Understanding
infinite always false always true
while ((i< 10) && (i > 24)) used in a test
number of
condition
times

The number of operands


30. in the conditional operator 3 4 2 5 A 73 NBF Knowledge
are:
Which kind of control
31. structure avoids repeating Sequence Choosing Repetition Selection A 70 NBF Knowledge
or skipping statements?

What will be the output of


following:
Hello Good Bye HelloGood Bye Compliation error
32. if (0) { cout << B 73 NBF Understanding
"Hello" ; } else { cout <<
"Good Bye" ; }
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain
Which operator can be
Conditional Bitwise
33. used in place of the if-else Bitwise operator Extraction Operator A 73 NBF Knowledge
operator operator
statement?
What will be the output of
following segment of the
code?
543 5432 54 321
34. for (int n = 5; n > 0; A 87 NBF Understanding
n--)
{ cout << n;
if (n == 3)
break; }
In a switch (i - k), which
35. case will be carried out if case 1 case 0 default case -1 D 76 NBF Understanding
i=2 and k=3?

What will be the output of


the following C++ code?
int n = 15; n will be printed
36. syntax error 15 Error C 81 NBF Understanding
for (; ;) infinite times
cout << n;
Option Ref Ref Bloom’s
Ser MCQ Ans
A B C D Pg Book domain

if (x % 2 != 0) then value
37. odd even prime negative A 83 NBF Understanding
of x will be:

The default scope of if only next only next next few


38. block of statements A 71 NBF Understanding
statement is: statement statement statements

What will be the output of


the following?
int x = 9;
39. 9876543210 987654321 9 0 D 83 NBF Understanding
while (x>0)
x - -;
cout<<x;
Anx A

APSACS PREP FOR ENTRY TESTS(PETS) PROGM - HSSC


Subject: Computer Science

Developer: Mr Fahad Aman CI /lvl: HSSC-II Title of the Chapter/ Concept: Array & String
Options Ref Ref Bloom's
Ser MCQs
A B C D Ans Pg Book Domain
1 The following is the general form of declaration of array datatype arrayname[arraysize]; datatype arraysize[arrayname]; arrayname[arraysize]; datatype arrayname(arraysize); a 97 NBF Analyses

The following is the general form of declaration of two dimensional datatype datatype datatype datatype
2 b 103 NBF Knowledge
array arrayname[row+column]; arrayname[row][column]; arrayname[column][row; arrayname[row*column];

In two dimensional array row and col written within ________


3 square curly square and curly row in square and col in curly a 103 NBF Knowledge
brackets

which functions is used to copy contents of a string variable or string


4 strlen(); strcmp(); strcpy(); strcpy[]; c 109 NBF Knowledge
constant to another string variable.

5 which functions is used for concatenation or joining of two strings. strcmp(); strcpy(); strlen(); strcat(); d 110 NBF Knowledge

6 Which functions is used to return the length of a string. strlen(); strcmp(); strcat(); strcpy(); a 110 NBF Knowledge

Which function is used to campares two strings and return an integer


7 strcat(); strlen(); strcpy(); strcmp(); d 111 NBF Analyses
value based on the result of comparision.

8 Which of the following is correct declaration of array? int arr; int arr[10]; int arr{10}; int arr(10); b 113 NBF Understanding

which of the following indentifies the first element in array named


9 temp[0]; temp[1]; temp(0); temp(1); a 113 NBF Analyses
temp?

10 which of the following statements will replace 10 with 20. arr[2][3] = 20; arr[0][10] = 20; arr[10][0] = 20; arr[10] = 20; d 113 NBF Understanding

Which of the following is the group of consecutive memory location


11 SimpleVariable Scalar Value Array Structure c 204 IT SERIES Knowledge
with same name and data type.

contigous allocation of memory is used to process large amount We can store different type of
12 Incorrect statement about An array: Always begin atindex 0 d 204 IT SERIES Knowledge
made up of elements of data of same type data

Every element in array has same The array size is fixed after it is the declared array size must be Every element in array has
13 Which of the following statement is not true? d 205 IT SERIES Knowledge
type created a constant expression different type

14 Each element of an array has its own: Membername Index uper bound dot operator b 205 IT SERIES Knowledge

The total number of elementsin an array


15 Index size of anarray upper bound lower limit b 205 IT SERIES Analyses
is called:

The index of an element in array is written


16 Angle brackets<> Square brackets[] parenthesis() curly braces{} b 205 IT SERIES Knowledge
wiithin:

Which of the following is used to access a specific element of an


17 Dot operator Index member name none b 205 IT SERIES Knowledge
array?

18 The index of the first element of an array ias always: 0 2 4 1 a 205 IT SERIES Understanding

19 What is the repesentation of the third element of an array called n? n[2] n[3] n[1] n[4] a 205 IT SERIES Understanding

20 Each element in arrqay has symbol ` unique index order data type b 205 IT SERIES Knowledge

21 Which of the following declares an array of 10 elements? float n[9] float n(9) float n[10] none c 205 IT SERIES Knowledge
Options Ref Ref Bloom's
Ser MCQs
A B C D Ans Pg Book Domain

22 Which of the following assigns the value 3.2 to first element? n(0)=3.2 n[0]=3.2 n(1)=3.2 n[1]=3.2 b 205 IT SERIES Understanding

23 How many elements are in int marks[5]? 5 6 4 0 a 205 IT SERIES Understanding

Where is 77 stored in n array?


24 n[0] n[1] n[2] n[4] c 205 IT SERIES Understanding
Int n[]={83.62.77.97}

25 How many elements are in int n[1000]? 1000 998 0 999 a 205 IT SERIES Understanding

what is the output?


26 Int n[4]={8.7.6.3}; 0 -1 1 3 d 205 IT SERIES Understanding
cout<<n[3];

what is the output?


27 Int n[]={56.90.86.97.120}; 97 98 99 90 a 205 IT SERIES Analyses
cout<<n[3];

28 Which of the following is correct int[6]={4.7.8.2.9.5}; int[6] {4.7.8.2.9.5}; int a [6]={4.7.8.2.9.5}; int a [6]{4.7.8.2.9.5}; c 205 IT SERIES Understanding

In the statement list[4]=3.3;


29 Membername Array name index variable d 206 IT SERIES Knowledge
The value 4 indicates:

Which of the following is a valid C++ array


30 void n[5]; int arr[20]; int arr[int]; none b 206 IT SERIES Knowledge
definition?

31 Which of the following is not valid: int i[]={3.4.3.2]; int i[4]={3.4.3.2]; double d[30]; int arr[10]; a 206 IT SERIES Understanding

32 A two dimensional array can be viewed as Argument.Parameter increment. Decrement rows,columns none c 206 IT SERIES Analyses

33 An array can be easily stepped through by using a: if switch for loop While loop c 206 IT SERIES Analyses

34 Which one declares an array with 3 rows and 5 columns? A double array [3].[5]; int array[3](int[5]); double array[3][5]; double array[3.5]; c 206 IT SERIES Analyses

35 Assume int t[]={1,2,3,4} What is t[4]? 0 3 4 t[4] is beyond array size d 206 IT SERIES Understanding

36 Which one is correct array for 10 rows and 5 columns? int [10][5] array; int array[10][5]; int arr [5][10]; none c 206 IT SERIES Knowledge

int a[4]={3.0.1.2}
37 3,2 0,2 3,0 0,4 c 206 IT SERIES Analyses
values of a[0] and a[1] are:

38 int sum[2][3]={(1,2),(3,4),(5,6)}; assigns a value 2 to num[1][2] assigns a value 4 to num[1][2] gives an error message assigns a value 3 to num[1][2] c 206 IT SERIES Knowledge

39 In float height[8][10], total number of elements will be 80 18 81 19 a 206 IT SERIES Understanding

Which function provides number of bytes occupied by the data type


40 sizeof() cap() sqrt() pow() a 206 IT SERIES Knowledge
given in ()?
the null character is
41 What is not true about string? it is a sequenceof character it is anarray of character automatically appended at the It store only digit value d 206 IT SERIES Knowledge
end

42 A string costant is written in: single quotes double quotes without quotes parenthes b 206 IT SERIES Analyses

43 Which of the following is null cahracter? \n \e \0 0 c 206 IT SERIES Knowledge

44 If the string need to store 25 cahracter, how is it defined? char str[25] char str[24] char str[26] char str[] a 207 IT SERIES Knowledge

45 If char city[ ]="Karachi"; what will be the size of string variable city? 8 7 9 none a 207 IT SERIES Analyses

46 Which is the correct statement? char str[ ]= "Object oriented' char str[20]="Object oriented" char str="Object oriented" Both a and b d 207 IT SERIES Knowledge
Options Ref Ref Bloom's
Ser MCQs
A B C D Ans Pg Book Domain
Which of the following functions is used to copy one string to
47 strcpy strcmp strcat strcant a 207 IT SERIES Analyses
another?

Which function is used to concatenate the contents of one string to


48 strcpy strcmp strcat strcant c 207 IT SERIES Analyses
another?

49 Which function is used to compare two strings? strcpy strcmp strcat strcant b 207 IT SERIES Analyses

50 What will strcmp() function return if string 1 and string 2 are same? 0 1 -1 none a 207 IT SERIES Understanding

What will strcmp() function return if


51 0 1 -1 none b 207 IT SERIES Understanding
string 1 is greater than string 2?

What will strcmp() function return if


52 0 1 -1 none c 207 IT SERIES Understanding
string 1 is less than string 2?

53 Which function is used to return the length of a string? strlen strlength len strsize a 207 IT SERIES Analyses

54 If x=5 which one accesses the seventh element is array A? A[x++] A[++x] A[7] A[x] a 207 IT SERIES Understanding

55 int number[5]={1,2,3}, what is stored in number[4]? 0 1 2 3 a 207 IT SERIES Understanding

What will be the output?


Int a=5;
56 int b=4; 46 47 48 49 d 207 IT SERIES Understanding
cout<<sizeof(a);
cout<<a+b;

57 Which one declares an array with 2 rows and 2 columns? A double array [2].[2]; int array[1](int[2]); double array[2][2]; double array[1.1]; c 206 IT SERIES Knowledge

58 Which of the following declares an array of 15 integer elements? float n[9] float n(9) float n[10] int n[15] d 205 IT SERIES Understanding

int n[5]={3.0.1.2,5}
59 3,2 0,2 0,5 0,4 b 206 IT SERIES Understanding
values of a[1] and a[4] are:
what is the output?
60 Int n[4]={8.7.6.3}; 6 -1 1 3 a 205 IT SERIES Knowledge
cout<<n[2];

61 How many elements are in int n[500]? 500 499 501 488 a 205 IT SERIES Understanding

Where is 81 stored in n array?


62 n[0] n[1] n[2] n[4] a 205 IT SERIES Knowledge
Int n[]={81.62.77.97}

63 What is the repesentation of the fourth element of an array called n? n[2] n[3] n[1] n[4] b 205 IT SERIES Knowledge

64 The index of the second element of an array is always: 0 2 4 1 d 205 IT SERIES Knowledge

65 If char str[ ]="fbise'"; what will be the size of string variable city? 8 7 9 6 d 207 IT SERIES Knowledge

66 Assume int n[]={1,2,3,4} What is n[3]? 0 3 4 1 c 206 IT SERIES Knowledge

what is the output?


67 Int n[5]={10.8.3.7,2}; 10 8 3 2 b 205 IT SERIES Knowledge
cout<<n[1];

68 If char city[ ]="lahore"; what will be the size of string variable city? 8 7 9 6 b 207 IT SERIES Knowledge

69 Which one declares an array with 6 rows and 2 columns? A double array [6].[5]; int array[6](int[2]); double array[6][2]; double array[6.2]; c 206 IT SERIES Analyses
Options Ref Ref Bloom's
Ser MCQs
A B C D Ans Pg Book Domain
what is the output?
70 Int n[]={16.20.26.27.12}; 16 20 26 27 d 205 IT SERIES Understanding
cout<<n[3];

Every element in array has same The array size is not 'fixed after it the declared array size must be Every element in array has
71 Which of the following statement is true about array? a 205 IT SERIES Analyses
type is created a variable expression different type
APSACS PREP FOR ENTRY TEST (PETS) PROGRAM HSSC

SCHOOL: APS&C BOYS (HAMZA) SUBJECT: COMPUTER SCIENCE

Developer: Qaisar Afzal Cl/lvl: XII Title of Chapter: Functions/Pointers

S. Option Ref Ref Bloom’s


MCQ Ans
No A B C D Pg Book Domain
1. Every C++ program must have at least
0 1 2 3 B 117 NBF Knowledge
how many functions?
2. The compulsory function of each C++ User
main() Built in Math
program is: defined A 117 NBF Knowledge
function function function
function
3. The puts() and time() are example of: User
main() Built in Math
defined B 129 KPK Knowledge
function function function
function
4. Which of the following is the default return
int char float void D 118 NBF Understanding
value of main function in C++?
5. When is inline function expanded? Compile Never end of
Run time A 143 KPK Understanding
time expands program
6. Where should default parameters appear Right Left most
in a function prototype parameter list? At middle Any where A 125 NBF Understanding
most side side
7. Which identifier is used to call the Return Name of Parameter Signature
B 131 KPK Knowledge
function? type function of function of function
8. The variables that hold the values of Return Name of Parameter Signature
C 119 NBF Knowledge
arguments while function is called: type function of function of function
9. Function prototype is not required when Before the Within the After the Anywhere
the function is defined: main main main in the A 121 NBF Understanding
function function function program
10. Actual functionality of function is always Function Function Function Main
C 121 NBF Understanding
specified in which component of function? prototype call definition function
11. What is nature of the following code Function Function Function Function
B 134 KPK Understanding
segment: sum(a,b,c); prototype call definition signature
12. What will be the output of the following
C++ code?
int sum(int x = 0, int y = 0, int z) Invalid
{ return (x + y + z); }
30 10 Error function A 134 KPK Application
int main()
{ call
cout << sum(5,10,15);
return 0;
}
13. In following code segment variables a,b Local Global Static Invalid
and c are:
Variables Variables Variables Variables
#include<iostream.h> A 123 NBF Understanding
using namespace std;
int main()
{ int a,b,c;}
14. In following code segment variables a,b Local Global Static Invalid
B 123 NBF Understanding
and c are: Variables Variables Variables Variables
#include<iostream.h>
using namespace std;
int a,b,c
int main()
{int sum=a+b+c;}
15. Which type of variable preserve the
Local Global Static Invalid
information about last value of function C 124 NBF Understanding
Variables Variables Variables Variables
returned?
16. In the following code segment the
variable x is:
Formal Actual Static Inline
A 140 KPK Understanding
void factorial(int x); Parameter Parameter Parameter Parameter
int main{ int y;
factorial(y); }
17. In the following code segment the
variable y is:
Formal Actual Static Inline
B 140 KPK Understanding
void factorial(int x); Parameter Parameter Parameter Parameter
int main{ int y;
factorial(y); }
18. In which type of function, the content of Built in User Global Inline
function is copied at the place of each function defined function function D 128 NBF Knowledge
function call during compilation? function
19. What are number of ways for passing
1 2 3 4 C 129 NBF Knowledge
arguments to a function?
20. In which type of argument passing Argument Argument Argument Default
method, the formal parameter is passed by passed by passed by argument C 147 KPK Knowledge
preceded by ampersand (&) sign? value constant reference
21. When is function overloading possible? Function Function Function Function
name is return arguments signature
D 151 KPK Understanding
different type is are are
different different different
22. Function signature is comprised of: Type of Number of Order of All of these
D 151 KPK Understanding
Parameter Parameter Parameter
23. What is advantage of function Increase Decrease Easy to All of these
D 137 NBF Knowledge
overloading? readability complexity remember
24. Function can be called: Before Within After main Anywhere
main main function in the D 152 KPK Understanding
function function program
25. In the following code segment which First Second Error Both
overloaded function will be called against function function message function
function call display();
C 139 NBF Understanding

void display();
int display();
26. Which is used to keep the call by
Static Constant Absolute Virtual A 149 KPK Understanding
reference value as intact?
27. By default, how is the value passed in By
By Value By Pointer By Object A 149 KPK Understanding
C++? Reference
28. What will be the output of the following
C++ code segment?
void copy (int& a, int& b, int& c)
{
a *= 2;
b *= 2;
c *= 2;
2510 254 2614 137 C 132 NBF Application
}
int main ()
{
int x = 1, y = 3, z = 7;
copy (x, y, z);
cout <<x<<y<<z;
return 0;
}
29. What will be the output of the following
C++ code segment?
void myvalue(int &x)
{
x = 20; 10 20 30 0 B 132 NBF Application
}
int main()
{
int x = 10;
myvalue(x);
cout << x;
return 0;
}
30. What will happen when we use void as It will It will not It may or It will not
return return may not return
return type of a function? B 120 NBF Knowledge
value to value to return value to its
its caller its caller value to caller by its
its caller object
31. What return type will be used if you are
static const virtual void D 120 NBF Knowledge
not intended to get a return value?
32. What should be return type of the function
that is supposed to print the table of a static const virtual void D 120 NBF Understanding
number?
33. Where does the return statement return To main To caller To same Ends the
the execution of the program? B 134 KPK Understanding
function function function program

34. What will be the output of the following


C++ code segment?
void Sum(int a, int b, int & c)
{
a = b + c;
b = a + c;
c = a + b; Error
23 69 215 C 132 NBF Application
} message
int main()
{
int x = 2, y =3;
Sum(x, y, y);
cout << x << y;
return 0;
}
35. What will be the output of the following
C++ code segment?
int max(int a, int b )
{
return ( a > b ? a : b );
} 5 7 5 or 7 13 B 133 KPK Application
int main()
{
int i = 5;
int j = 7;
cout << max(i, j );
return 0; }
36. Which value will function take when both User Default Both Error
user and default values are given? A 134 NBF Understanding
Value Value Values Message
37. What will be the output of the following
C++ code?
int func(int m = 10, int n)
{
int c;
Error
c = m + n; 10 15 5 B 134 NBF Application
return c; } Message
int main()
{
cout << func(5);
return 0;
}
38. Where does the execution of the program User Main Void Header
starts?
defined function function files B 130 KPK Understanding
function
39. Which of the following is used to : , ; )
C 131 KPK Understanding
terminate the function declaration?
40. Which is more effective while calling the Call by Call by Call by Call by
functions? B 133 NBF Understanding
value reference pointer object
41. What is the scope of the variable In whole In main In user In all
declared in the user defined function? program function defined functions C 136 KPK Knowledge
function
42. Which of the following function int int int All are
declaration using default arguments is myfnc(int myfnc(int myfnc(int
correct B 134 NBF Understanding
incorrect? x, int y =5, x=10, int y x=20, int y
int z=10) =5, int z) =5, int
z=10)
43. What is the output of the following code
segment?
void subject()
{ cout<<”Computer”; }
Computer Compile
void subject() Computer Science D 151 KPK Application
{ cout<<"Science"; } Science time error
int main()
{ subject();
return 0; }

44. What is the output of this program?


using namespace std;
10
void get(int &p, int q)
{ 20 1010 2020 B 135 NBF Application
p = 20;
q = 10;
}
int main()
{
int p = 10;
get(p, p);
cout << p;
return 0;
}
45. The parameters are passed by reference
* # $ & D 133 NBF Knowledge
by which symbol?
46. What is the output of this code segment? 5 30 35 15
void print(int &p)
{
p = 30;
}
int main() B 133 NBF Application
{
int p = 5;
print(p);
cout<< p;
return 0;
}
47. Function prototype for built in functions Header Source file Object file Image file
are specified in which file? A 129 KPK Knowledge
file
48. The value of which variables remain in Normal Constant Local Static
the memory till the end of a program? D 139 KPK Knowledge
variables variable variables variables
49. Why pointers are used? To store To store To store To store
the constant address of the C 142 NBF Knowledge
variables values variables functions
50. The width of memory address depends Computer Computer Computer Computer
on what?
Software Hardware Memory Architectur D 139 KPK Knowledge
e
51. Which operator is used to make the Reference Dereferen Arithmetic Logical
variable, a pointer variable?
operator ce operator operator A 163 KPK Knowledge
operator
52. Reference operator is denoted by which # & * $ B 163 KPK Knowledge
symbol?
53. Which operator is used to store the value Reference Dereferen Arithmetic Logical
of another variable in pointer variable?
operator ce operator operator B 164 KPK Knowledge
operator
54. Dereference operator is denoted by which # & * $ C 164 KPK Knowledge
symbol?
55. What will be output of following code 5 10 Address Address of
segment?
of z x
int x=5,y=10; D 144 NBF Application
int *z;
z=&x;
cout<<&x;
56. What will be output of following code 5 10 Address Address of
segment?
of z x
int x=5,y=10; D 164 KPK Application
int *z;
z=&x;
cout<<z;
57. What will be output of following code 5 10 Address Address of
segment? A 164 KPK Application
of z x
int x=5,y=10;
int *z;
z=&x;
cout<<*z;
58. Which type of pointer can object to any Null Void Integer Float
data type? B 146 NBF Knowledge
pointer pointer pointer pointer
59. Which is correct way to declare pointer int *x; int x*; int &x; int x&; A 147 NBF Knowledge
variable?
60. What will happen in the following C++ b points to p points to a points to q points to
code snippet? a b b
a B 165 KPK Application
int a = 100, b = 200;
int *p = &a, *q = &b;
p = q;
61. Which of the following gives the value
stored at the address pointed by the value ptr ptr *ptr &ptr; C 164 KPK Understanding
pointer : ptr?
62. A pointer can be initialized with: Address
Address of
null zero of an C 146 NBF Knowledge
an object
object of
of any type
same type
63. What is size in bytes of generic pointer in Depends
c++?
on
0 1 2 architectur D 146 NBF Understanding
e of
computer
64. Referencing a value through a pointer is Direct Indirect Pointer Pointer
called? Referenci C 163 KPK Knowledge
calling calling accessing
ng
65. What will be the output of the following
Address of
C++ code? 5 10 15 B 144 NBF Application
#include <iostream> variable a
using namespace std;
int main()
{
int a = 5, b = 10, c = 15;
int *arr[3] = {&a, &b, &c};
cout <<* arr[1];
return 0; }
66. The process to access data in a variable Referenci Dereferen Accessing Pointing a
using * operator with pointer variable is ng a cing a a pointer pointer B 164 KPK Knowledge
called: pointer pointer
67. If double *ptr_total = &total; what will be Address Value of Address Value of
printed by the statement: cout<< of total total of ptr_total C 144 NBF Understanding
&ptr_total; ptr_total
68. Which of the following assigns the A 162 KPK Understanding
address of x to the pointer p1? *p1 = &x p1=x p1=&x &p1=*x;
69. Which of following statements is true after
executing the following code? p points to p points to
p holds p holds
char x= ‘m’; variable x variable x D 143 NBF Understanding
the value the value
char * p = &x; which has which has
m w
*p = ‘w’; value m value w

70. By using pointers, how many value(s) can Single Double Triple Multiple D 161 KPK Knowledge
be returned from function? value values values values
TOS: Table of Specification

S.No Questions Knowledge Understanding Application


1. Every C++ program must have at least how many functions? P
2. The compulsory function of each C++ program is: P
3. The puts() and time() are example of: P
4. Which of the following is the default return value of main function in
C++?
P

5. When is inline function expanded? P


6. Where should default parameters appear in a function prototype
parameter list?
P

7. Which identifier is used to call the function? P


8. The variables that hold the values of arguments while function is
P
called:
9. Function prototype is not required when the function is defined: P
10. Actual functionality of function is always specified in which
P
component of function?
11. What is nature of the following code segment: sum(a,b,c); P
12. What will be the output of the following C++ code?
int sum(int x = 0, int y = 0, int z)
P
{ return (x + y + z); }
int main()
{
cout << sum(5,10,15);
return 0;
}
13. In following code segment variables a,b and c are:
#include<iostream.h> using namespace std; P
int main() { int a,b,c;}
14. In following code segment variables a,b and c
are:#include<iostream.h>
using namespace std; i P
nt a,b,c;
int main()
{int sum=a+b+c;}
15. Which type of variable preserve the information about last value of
P
function returned?
16. In the following code segment the variable x is:
void factorial(int x);
int main() P
{ int y;
factorial(y); }
17. In the following code segment the variable y is:
void factorial(int x);
int main() P
{ int y;
factorial(y); }
18. In which type of function, the content of function is copied at the
P
place of each function call during compilation?
19. What are number of ways for passing arguments to a function? P
20. In which type of argument passing method, the formal parameter is
P
preceded by ampersand (&) sign?
21. When is function overloading possible? P
22. Function signature is comprised of: P
23. What is advantage of function overloading? P
24. Function can be called: P
25. In the following code segment which overloaded function will be
called against function call display(); P
void display();
int display();
26. Which is used to keep the call by reference value as intact? P
27. By default, how is the value passed in C++? P
28. What will be the output of the following C++ code segment?
void copy (int& a, int& b, int& c)
{
a *= 2;
b *= 2;
c *= 2;
} P
int main ()
{
int x = 1, y = 3, z = 7;
copy (x, y, z);
cout <<x<<y<<z;
return 0;
}
29. What will be the output of the following C++ code segment?
P
void myvalue(int &x)
{
x = 20;
}
int main()
{
int x = 10;
myvalue(x);
cout << x;
return 0;
}
30. What will happen when we use void as return type of a function? P
31. What return type will be used if you are not intended to get a return
value?
P

32. What should be return type of the function that is supposed to print
the table of a number?
P

33. Where does the return statement return the execution of the P
program?
34. What will be the output of the following C++ code segment?
void Sum(int a, int b, int & c)
{
a = b + c;
b = a + c;
c = a + b;
} P
int main()
{
int x = 2, y =3;
Sum(x, y, y);
cout << x << y;
return 0;
}
35. What will be the output of the following C++ code segment?
int max(int a, int b )
{
return ( a > b ? a : b );
}
P
int main()
{
int i = 5;
int j = 7;
cout << max(i, j );
return 0; }
36. Which value will function take when both user and default values are P
given?
37. What will be the output of the following C++ code?
int func(int m = 10, int n)
{
int c;
c = m + n;
return c; } P
int main()
{
cout << func(5);
return 0;
}
38. Where does the execution of the program starts? P
39. Which of the following is used to terminate the function declaration? P
40. Which is more effective while calling the functions? P
41. What is the scope of the variable declared in the user defined
function?
P
42. Which of the following function declaration using default arguments
is incorrect?
P

43. What is the output of the following code segment?


void subject()
{ cout<<”Computer”; }

void subject()
{ cout<<"Science"; }
P
int main()
{ subject();
return 0; }

44. What is the output of this program?


using namespace std;
void get(int &p, int q)
{
p = 20;
q = 10;
} P
int main()
{
int p = 10;
get(p, p);
cout << p;
return 0;
}
45. The parameters are passed by reference by which symbol? P
46. What is the output of this code segment?
void print(int &p)
{ P
p = 30;
}
int main()
{
int p = 5;
print(p);
cout<< p;
return 0;
}
47. Function prototype for built in functions are specified in which file? P
48. The value of which variables remain in the memory till the end of a P
program?
49. Why pointers are used? P
50. The width of memory address depends on what? P
51. Which operator is used to make the variable, a pointer variable? P
52. Reference operator is denoted by which symbol? P
53. Which operator is used to store the value of another variable in P
pointer variable?
54. Dereference operator is denoted by which symbol? P
55. What will be output of following code segment?
int x=5,y=10;
int *z; P
z=&x;
cout<<&x;
56. What will be output of following code segment?
int x=5,y=10;
int *z; P
z=&x;
cout<<z;
57. What will be output of following code segment? P
int x=5,y=10;
int *z;
z=&x;
cout<<*z;
58. Which type of pointer can object to any data type? P
59. Which is correct way to declare pointer variable? P
60. What will happen in the following C++ code snippet?
int a = 100, b = 200; P
int *p = &a, *q = &b;
p = q;
61. Which of the following gives the value stored at the address pointed P
by the pointer : ptr?
62. A pointer can be initialized with: P
63. What is size in bytes of generic pointer in c++? incorrect answer P
64. Referencing a value through a pointer is called? P
65. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{ P
int a = 5, b = 10, c = 15;
int *arr[3] = {&a, &b, &c};
cout <<* arr[1];
return 0; }
66. The process to access data in a variable using * operator with P
pointer variable is called:
67. If double *ptr_total = &total; what will be printed by the statement: P
cout<< &ptr_total;
68. Which of the following assigns the address of x to the pointer p1? P
69. Which of following statements is true after executing the following
code?
char x= ‘m’; P
char * p = &x;
*p = ‘w’;
70. By using pointers, how many value(s) can be returned from function? P

Total 70 28 28 14
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science

Developer: Ms. Mahnoor Imran Title of the Chapter / Concept: Chapter#8 (Classes & Objects)
Option Ref Ref Bloom's
Ser MCQ Ans
A B C D Pg Book domain

In C++, objects are also An instance of


1. A function A variable Both a & C C 173 KPK Knowledge
called? class
Objects are
Objects have Objects are Objects have
How is an object different predefined,
2. methods, classes instances of data members, B 152 NBF Knowledge
from class in C++. classes are
don’t classes classes don’t
user defined
A programming technique
Procedural Non- procedural
in which in programs are Object oriented
3. Programming programming Both a & b B 150 NBF Understanding
written on the basis of approach
approach approach
objects is called:
The attribute of the class Member
4. Data member Methods Object A 171 KPK Knowledge
are called: function
Which of the following is
5. Public Private Class Botha & b C 171 KPK Knowledge
user defined data type.
Which of the following are
Virtual and Private and
6. the types of access Sub and class Null and void C 155 NBF Knowledge
function public
specifier?
Which of the following
Overridden Friend
7. function of class is Destructor Constructor C 159 NBF Understanding
function Function
automatically executed
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
when an object of class is
created?
The same name
as that of class
Which of the following is It is always
8. It has return type but a tilde sign is All C 159 NBF Understanding
true about constructors? public
used before its
name
Which of the following It must have the It is optional to
It can have any
9. statement is true about the same name as have any name All B 159 NBF Understanding
name
name of constructors? that of class for constructors
Can a class have multiple
Yes, but only if No, it will result No, it will
constructors with the same Yes, but only if
10. they have in compilation result in C 163 NBF Understanding
name and types of they are private
different names error runtime error
parameters?
Constructors
can be
Which of the following is Has same name Constructor is It has return overloaded
11. D 159 NBF Understanding
false about constructors? as that of class always public type on the basis
of return
type
Which of the following is
automatically executed Overridden Friend
12. Destructor Constructor B 164 NBF Understanding
when object of the class is function Function
destroyed?
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
It has same
Which of the following is name as that of Destructor can be Destructor can
13. Both B & C D 164 NBF Knowledge
false about destructors? class preceded overloaded take arguments
by tilde symbol
What is a class in Object – A blueprint for
14. A function A Variable A loop C 171 KPK Understating
Oriented Programming creating object
What is the purpose of a To allocate To initialize To define
15. To destroy object C 179 KPK Understanding
constructor in C++? memory objects functions
Which access Specifier
allows the member of class
16. Public Private Protected Friend A 179 KPK Understanding
to be accessed from any
part of the program?
What is the default access
17. specifier for members of Public Private Protected Static B 177 KPK Knowledge
C++ class?
What is the primary For perform
To declare To group related To model real
18. Purpose of using Classes mathematica B 171 KPK Knowledge
Variables functions world entities
in C++? l operations
In C++, what is destructor To initialize To deallocate To define
19. To create objects A 184 KPK Knowledge
used for? objects memory class
Which Concept in C++
allows a class to inherit
20. Composition Encapsulation Polymorphism Inheritance D 167 NBF Knowledge
properties and behavior
from another class
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
How do you access a
Object[mem
21. public member of an object Object.member Object->member Object::member A 165 NBF Apply
ber]
in C++?
In C++, which one of the A variable A variable
A variable with A loop
22. following is class member declared in the declared within B 165 NBF Knowledge
global scope variable
variable? main() the class
Suppose you have a class
‘Rectangle’ with attributes
‘length’ and ‘width’. Which void
double double
23. function would you setvalue(double l, calculate() A 166 NBF Application
computeArea() setdimensions()
implement to calculate and double w)
return the area of rectangle
of object?
If you have a class ‘Person’
with attributes ‘name’ and
String displayPerso
24. ‘age’ which function could Void showInfo(); int getAge(); A 166 NBF Application
printdetails (); n();
be used to display the
details of a person object?
In C++, if you want to
ensure that a member
variable cannot be
25. Public Private Protected Friend B 177 KPK Understanding
modified outside the class,
what access specifier
would you use?
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
In C++, where the data
In the global Outside class Inside class
26. member for class usually In the main() D 175 KPK Knowledge
scope definition definition
declared?
It can be It can only be It can be
In C++, what does it mean It can only be
assessed from accessed only accessed by
27. if a class member is accessed only D 179 KPK Understanding
any part of within the same the derived
declared as ‘protected’? within the class
program file classes
To control the
What is the purpose of To allocate
To define the visibility and To declare
28. access specifiers in C++ memory for B 176 KPK Understanding
size of class accessibility of objects
class? class objects
class
Which type of constructor
Default Parameterized Both are called
29. is called when object is Error occur A 161 NBF Understanding
Constructor Constructor simultaneously
created with no arguments
The word explicit is
With
associated with With default Both with a
30. parameterized With destructor B 162 NBF Understanding
____________ type of constructor &b
constructor
constructors.
To initialize the
To allocate object attributes To create copy
What is the purpose of To destroy
31. memory for with values of an existing B 162 NBF Understanding
parameterized constructor? object
objects passed as object
parameters
32. Which of the following is Using the same Defining multiple Creating Calling one B 163 NBF Knowledge
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
correct definition of constructor constructors with constructors constructor
constructor overloading in multiple times the same name with different from another
C++. but different return types
parameters
Can a constructor be Only for
Only for default
33. overloaded on the basis of Yes No explicit B 163 NBF Knowledge
constructors
return types? constructors
Based on
How does the compiler Based on By using the
parameters’ data Based on order
34. differentiate between constructors ‘overload’ B 162 NBF Understanding
types and/or of declaration
overloaded constructors? name keyword
number
A class can have how
35. 1 2 3 Any number A 164 NBF Knowledge
many destructors?
The ability of class to
derive properties from Data Information
36. Polymorphism Inheritance B 167 NBF Understanding
previously defined class is Encapsulation hiding
called
Which of the following
37. class inherits all the Abstract Class Super Class Parent Class Child Class D 186 KPK Knowledge
capabilities of base class?
If class A inherits from
class B, then class B is Parent class, Sub class, Parent Abstract Class, Child Class,
38. A 188 KPK Understanding
called _________ of A. A is Sub Class Class Base Class Sub Class
called ___________of B.
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
Private
Protected Protected
How does the ‘protected’ There is no members
members are members are
39. access specifier differ from difference can be B 159 NBF Apply
accessible only accessible from
‘private’ in C++ classes? between them accessed
within the class derived classes
globally
By
How does data hiding By exposing all By restricting By allowing
eliminating
40. contribute to the concept of the class data access to certain global access to B 159 NBF Analyze
the need for
encapsulation in C++? publicly members data
classes
Which of the following is an
Myclass() Myclass (int x) Myclass All of the
41. example of constructor D 163 NBF Apply
{} {} (double y) { } above
overloading?
Which of the following
correct syntax for declaring Car.create
42. Car myCar; Car myCar(); new Car; A 152 NBF Understanding
an object of class ‘Car’ in ();
C++.
What happens if you try to
It has no
access a private member Compiler error Runtime error Successful
43. impact on A 156 NBF Apply
of an object directly outside occur occur execution
program
its class?
Parameterized Parameterized Default Default
How does a parameterized
constructors constructors take constructors are constructors
44. constructor differ from a B 182 KPK Understanding
have default parameters for not allowed to are not used
default constructor?
values initialization have in C++
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
parameters
The compiler
If a class does not explicitly The class
automatically Objects of the
define a constructor, then The class can’t can’t be
45. generates a class cannot be B 181 KPK Understanding
which type of constructor is have objects used in a
default initialized
called? program
constructor
The ability of a
The polymorphism in C++ A programming A type of
46. function to take A loop B 188 KPK Knowledge
is technique variable
on different forms
Which type of inheritance
allows a class to inherit Single Multiple Multilevel Hierarchal
47. B 169 NBF Understanding
from multiple base Inheritance Inheritance Inheritance Inheritance
classes?
Consider a base class “
Vehicle” and a derived Car can access Car can inherit all Vehicle
48. class” Car”. How does private members the properties of becomes an All B 186 KPK Application
inheritance help in this of vehicle Vehicle instance of Car
scenario?
What is the main Data
Function
49. advantage of using Code reusability Memory allocation Encapsulatio A 167 NBF Knowledge
Overloading
inheritance in C++? n
If class B is derived from Both functions It depends
The function in The function in
50. class A, and both classes will be called on the B 169 NBF Application
class A class B
have member function with simultaneously access
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
the same name, which specifier
function will be called when
an object of class B
invokes that function?
It is a It is defined
It is defined by
Which of the following It is provided by constructor that by the user
the user to
51. statement is true about the compiler initializes class to initialize D 162 NBF Understanding
allocate memory
user defined constructors automatically members with class
for class objects
default values members
If a class has both a default
constructor and user It depends
Both
defined constructors, which Default User defined on the order NBF
52. constructors are A 161 Understanding
constructor is called when Constructor constructor in which they
called
an object is created without are defined
providing any argument?
Consider a class ‘Book’
with constructor that
initializes the title and
Book b = new
53. author. How can you Book b(); Book b; Book b (“ ”) C 163 NBF Application
Book;
create a Book object
without providing any
arguments?
In the class ‘Car’ there is a Car Car Car c=
54. Car c(); B 182 KPK Application
constructor ‘Car (string c=Car(“Sedan”, c(“Sedan”,2022); Car(“Sedan”,
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
model, int year)’. How 2022); 2022);
would you create a Car
object with the model
“Sedan” and the year
2022?
Given a class ‘Person’ with
a parameterized
constructor that accepts Person p(“john”, Person p=
55. Person p(); Person p; C 182 KPK Application
‘name’ and ‘age’ how can 25); new Person;
you create an object of this
class?
In a class ‘Person’ with
private members ‘name’
and ‘age’, which access
56. Public Private Protected Friend C 179 KPK Application
specifier would you use for
member ‘age’ to allow
access in derived classes?
Members of Object of
Member of class Objects of class
If a class ‘A’ is declared as class A can class B can
B can access A can be
57. a friend in class ‘B’, what access private be B 159 NBF Understanding
private members instantiated in
does it mean? members of instantiated
of class A class B
class B in class A
In a class ‘car’ with private mycar.setspeed(6 mycar.speed=6 setspeed(my
58. car.speed=60; B 154 NBF Application
member ‘speed’, which of 0); 0 car,60)
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
the following is a correct
way to set the speed of an
object named ‘mycar’?
If a class has a public data
member ‘count’ , how can myobject.getco myobject::co
59. count; myobject.count; B 178 KPK Understanding
you access its value from unt(); unt;
outside the class?
It allows access It restricts
It allows access to
Which of the following to members of access to It declares
members from
60. statement is true about within the same members from the member C 159 NBF Understanding
any part of the
private access specifier? class and its outside the as constants
program
derived class class
A class is
A class is a
blueprint for There is no
What is the difference A class is an function,
objects, while an difference
61. between a class and an instance of an while an B 151 NBF Knowledge
object is an between class
object in C++? object object is a
instance of a and objects
variable
class
Members of the class are Resolution Extraction
62. Address Operator Dot operator C 153 NBF Understanding
accessed with Operator Operator
Which section of a class
63. can a member function of Private Protected Public All D 179 KPK Understanding
that class access
64. The object of class Data members Member function Tag Both a & b D 152 NBF Knowledge
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
contains
Another name used for
65. Parent Class Super Class Child Class Both a & b D 186 KPK Knowledge
base class is
Which of the following
function of a class cannot Overridden Friend
66. Destructor Constructors B 185 KPK Understanding
take arguments and has no function Function
return type?
Which of the following
function of a class take Overridden Friend
67. Destructor Constructors C 183 KPK Understanding
arguments but has no function Function
return type?
The mechanism that binds
code and data together Polymorphis
68. Abstraction Encapsulation Inheritance B 178 KPK Knowledge
and keeps them secure m
from illegal access is
Public
Private members
Public members
Public members members of the of the base
Which of the following of the base class
of the base class base class class
statements is correct when become
69. become private become become D 169 NBF Understanding
a class is inherited protected
members of protected public
publicly? members of
derived class. members of members
derived class
derived class. of derived
class.
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
Destructor has same name
70. as that of class preceded @ # $ ~ D 164 NBF Understanding
by
State whether the following
statements about the
constructor are True or
False. i) constructors
71. should be declared in the True, True True, False False, True False, False C 159 NBF Understanding
private section. ii)
constructors are invoked
automatically when the
objects are created.
Which of the following
implicitly creates a default
constructor when the
72. programmer does not Preprocessor Linker Loader compiler D 161 NBF Understanding
explicitly define at least
one constructor for a
class?
How many access
73. specifiers are available in 1 2 3 4 C 159 NBF Knowledge
C++?
Which operator is used to Scope resolution Direct member
74. Ternary operator None C 153 NBF Understanding
access the object of class? operator access operator
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
Which of the following
keyword is used to control
75. Default Break Protected hide C 159 NBF Understanding
the access to class
member?
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science

Developer: Ms. Mahnoor Imran Title of the Chapter / Concept: Chapter#9 (File Handling)
Ref Ref Bloom's
Option Ans
S# MCQ Pg Book domain
A B C D
Which library is used in
1. iostream fstream ifstream cfile B 194 KPK Knowledge
C++ for file handling?
2. A file is stored in Ram Hard Disk ROM Cache B 194 KPK Knowledge
Which of the following are
3. Opening Closing Read/ Write ALL D 195 KPK Knowledge
file handling operation?
The classes ifsteam,
4. ofstream and fstream are iostream conio.h fstream.h ifstream.h C 195 KPK Knowledge
defined in the header file
To handle text
To manage
What is the purpose of file To manipulate input/output To control
5. memory B 194 KPK Understanding
handling in C++? directories operations on user input
allocation
files
What is the default mode
6. ios::in ios::out ios::binary ios::app B 176 NBF Knowledge
for file opening in C++?
Which function is used to
7. open() fopen() ifstream() ofstream() D 176 NBF Knowledge
open a file in C++?
Which mode is used for
ios::in |
8. reading and writing in a file ios::in ios::out ios::app D 177 NBF Knowledge
ios::out
simultaneously?
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
How do you close a file in
9. close() fclose() closefile() fclosefile() A 200 KPK Knowledge
C++?
Which operator is used to
10. >> << >| |> A 197 KPK Knowledge
read from a file in C++?
Which function is used to
11. read ( ) get( ) put( ) write( ) C 197 KPK Knowledge
write to a file in C++?
It allows both
What is the purpose of It allows It treats the file
It allows reading reading and
12. ios::binary mode in file writing binary contents as C 195 KPK Knowledge
binary files only. writing binary
handling files only binary data.
files.
Which function is used to
13. check the end of a file in eof( ) end_of_file( ) is_end( ) file_end( ) A 201 KPK Knowledge
C++?
What is the purpose of the Sets the initial
Appends text at Opens a file in Reads a file
14. ios::ate mode in file position at the C 195 KPK Knowledge
the end of a file. append mode. from the end
handling? end of the file.
How do you read a single
readCharFrom
15. character from a file in readChar( ) get( ) read( ) B 205 KPK Knowledge
File( )
C++?
Opens a file at
What does the ios::app Opens a file in Opens a file in Opens a file in
16. the end A 195 KPK Knowledge
mode do in file handling? append mode. read mode. write mode.
position
Which function is used to
17. open( ) fopen( ) openfile( ) fstream( ) D 196 KPK Knowledge
open a file for both reading
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
and writing in C++?
What happens if we It displays a
It throws an It generates It create the
18. attempt to open the file that warning C 199 KPK Understanding
exception an error code new file
doesn’t exist? message
Which stream class is to
19. Ofstream Ifstream Fstream Iostream A 204 KPK Knowledge
only write on files
Returns true if Returns true if Returns true if Returns true if
file opening for file opening for file opening for file opening for
Which of these is correct
20. reading has reading has reading has reading has C 181 NBF Understanding
about eof() statement
reached the next reached the reached the reached the
character next word end middle
Which operator is used to
21. insert data into files in << >> < Both a & c A 196 KPK Understanding
C++?
Which operator is used to
22. << >> < > B 196 KPK Understanding
read data into file in C++?
When get()
The get() returns EOF End of file is When program
23. fails to read a Both A & B D 183 NBF understanding
when reached terminates
character
By default all the files are Sequential
24. Binary Mode Text Mode Both A & B B 194 KPK Understanding
opened in _______ mode . Mode
To open a file in To open a file To truncate an To truncate an
What is the use of ios::trunc
25. input mode in output existing file to existing file to D 176 NBF Understanding
mode?
mode half zero
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science

Which of the following is


the default mode of the
26. ios::in ios::out ios::app ios::trunc A 177 NBF Understanding
opening using the ifstream
class?
Which of the following is
the default mode of the
27. ios::in ios::out ios::in | ios::out ios::trunc C 177 NBF Understanding
opening using the fstream
class?
Which of the following is
the default mode of the
28. ios::in ios::out ios::in | ios::out ios::trunc B 177 NBF Understanding
opening using the ofstream
class?
Which of the following is
29. ios::in ios::out ios::trunc ios::ate C 195 KPK Understanding
not a file opening mode?
To create an output stream,
30. we must declare the stream ofstream ifstream iostream None of these A 204 KPK Knowledge
to be of class ?
The _______ class of
stream will perform both
31. iostream ofstream ifstream fstream D 204 KPK Knowledge
input and output
operations?
How many parameters are
32. 1 2 3 4 B 196 KPK Understanding
used in open() function?
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
Which of the following
33. types of file can be used for .dat .txt .doc ALL D 194 KPK Understanding
both read/write operation?
Which of the following is file
34. ios::in ios::out ios::read ios::ate A 195 KPK Knowledge
reading mode in C++?
Which of the following is
35. used to move file pointer to eof() bof() fopen() All B 181 NBF Knowledge
the start of a file?
Which of the following is
myfile@close(
36. correct syntax for closing a myfile$close(); myfile:close(); myfile.close(); D 181 NBF Knowledge
);
file?
37. Eof() is used to get End of file End of Field End on file File or file A 181 NBF Knowledge
How do you open a file Ofstream ifstream Ofstream fstream
38. named “data.txt” in write file(“data.txt”, file(“data.txt”, file(“data.txt”, file(“data.txt”, C 195 KPK Understanding
mode? ios::in): ios::out); ios::out); ios::read);
What is the purpose of To terminate the To save data To close an
39. To delete a file C 181 NBF Understanding
close() function? program to file opened file
fstream
fstream fstream fstream
How do you open a file in file(“data.txt”,
40. file(“data.txt”, file(“data.txt”, file(“data.txt”, A 195 KPK Understanding
both read and write mode? ios::read |
ios::in | ios::out); ios::readwrite); ios::both);
ios::write);
Which function would you
41. use to read characters Get() Getline() Read() Ignore() A 183 NBF Understanding
excluding newline
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
characters?
The _________ is the
sequence of bytes of
Array of
42. infinite length that is used String Stream File B 203 KPK Knowledge
Characters
as buffer to hold data to be
processed.
The stream is _________
43. Logical Conceptual Physical All A 203 KPK Knowledge
interface to file.
The __________ loop is
44. suitable for getting data For loop While loop Do-while loop Nested loop B 202 KPK Knowledge
from an input file stream
The _________ loop is
suitable when you know the
45. For loop While loop Do-while loop Nested loop A 202 KPK Knowledge
exact number of data items
in the file.
Which function is used to
46. read a line from the file into getline() putline() readline() read_line() A 200 KPK Understanding
string?
Which function is used to
47. read integers from file cin>> readint() get() read() A 200 KPK Understanding
stream?
When we want to write the
48. “Hello world” to the file ios::out ios::app ios::ate ios::in B 195 KPK Application
exisiting.txt without
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
overwriting its current
content, which file opening
mode will be used?
You're opening a file in C++
to write data and want to
keep the existing content
intact. If the file doesn't
ios::out | ios::out | ios::out | ios::out |
49. exist, a new one should be A 195 KPK Understanding
ios::app ios::trunc ios::ate ios::in
created.
Which file opening mode in
C++ satisfies these
requirements?
Which file opening mode
No specific
will be used to perform
50. ios::binary ios::ate ios::app mode for D 195 KPK Understanding
buffered reading & writing
buffering
operation in C++?
To release
system To prevent
What’s the primary purpose To delete the file To clear the
51. resources future file B 200 KPK Understanding
of closing a file in C++? from the system file content
associated access
with the file
What would be the exit
file.eof()!=fals
52. condition for loop when file.eof()==false file.eof()==true file.eof()!=true B 180 NBF Understanding
e
using ‘while(!file.eof())’ in
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
C++
Which stream object will be ifstream /
53. used for binary input/output cin cout fstream ofstream with D 204 KPK
in C++? ios :: binary
Which stream object will be
54. used for writing data to the cin cout ifstream ofstream B 206 KPK
console?
What is the return type of
55. bool int char void A 203 KPK Understanding
eof() function in C++?
Which stream objects are
Cin & Cout &
56. used to handle both user Cin & ifstream Cout & ifstream A 205 KPK Understanding
ofstream ofstream
input and file input?
Which condition is checked Both are
Beginning-of- It depends on
57. first while processing a file End-of-File checked B 201 KPK Understanding
File the size of file
in C++? simultaneously
What does ifstream:: eof()
It throws an Creates new
58. methods returns when the True False A 182 NBF Understanding
exception file
end of file is encountered?
Which possible error may
occur when file is not
59. Data Loss Memory Leak File corruption All D 200 KPK Understanding
closed before the program
terminates in C++?
Which function in C++ allow
60. skip() ignore() read() get() B 200 KPK Understanding
us to skip undesirable
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
characters in input file
stream
Which file opening mode in No specific
61. C++ facilitates buffered ios::ate ios::binary ios::app mode for D 195 KPK Understanding
operation? buffering
A file that A file that is
A file that A file that has
In context to binary files, contains encrypted for
62. contains text executable A 194 KPK Knowledge
what is binary file? machine security
character code
readable data purposes
Occupy less Ensure
Which statement is correct memory as Faster data portability Human Both
63. 194 KPK Understanding
about binary files in C++? compared to text retrieval across different readable A&B
file systems
Opens the file
What does ios::ate | Opens the file for writing at
Opens the file Opening file
64. ios::app mode do when for reading at the end B 195 KPK Understanding
in binary mode for appending
opening a file? the end without
truncation
What does is_open()
True if file is True if file True if file is True if file can
method return when called
65. open, false exists, false empty, false be read, false A 194 KPK Understanding
on an’ifstream’ object after
otherwise otherwise otherwise otherwise
opening a file?
Which of the following Ios::trunc |
66. Ios::in Ios::app Ios::out D 195 KPK Understanding
mode is used to open a file ios::out
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
for writing, truncating the
file to zero if it exists?
Which of the following
mode is used to open a file
Ios::trunc| Ios::in| ios::out|
67. for reading and writing , Ios::in| ios::out Ios::in| ios::out D 195 KPK Understanding
ios::ate ios::trunc
starting at the beginning of
file without truncating
What happen if the file is
Data will be File become Memory leaks
68. closed multiple times in No issue arise D 201 KPK Understanding
corrupted in file inaccessible in application
C++?
Which of the following
statements are correct?
• It is not possible to
combine two or more
file opening mode in
open() method.
• It is possible to 1,3
69. 2,3 3 only 1,2 B 176 NBF Understanding
combine two or more
file opening mode in
open() method
• ios::in and ios::out are
input and output file
opening mode
respectively.
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
The return type of open()
70. Int Float Bool Char C 177 NBF Understanding
method is:
In C++ which mode is used
71. Trunc Truncate Delete Empty A 176 NBF Understanding
to empty the file?
Which of the following is
72. used to move the pointer to \r \n \b \t B 175 NBF Understanding
next line in C++?
Which mode creates new None of the
73. Write mode Append mode Both a & b C 177 NBF Understanding
file when file doesn’t exist? above
Which of the following
classes are used for file
handling in C++?

74. A. fstream A&B A&D A, B & C A, B, C & D C 177 NBF Knowledge


B. ifstream

C. ofstream

D. ostream

Which of the following


statements are correct
about the fstream class in
C++?
75. A&B A&D A, B & C A, B,C & D C 177 NBF Understanding
A. This is used to read
data from the file.
B. This is used to write
data into the file
APSACS PREP FOR ENTRY TESTS (PETS) PROGM - HSSC
School: APSAC FFC ATD Subject: Computer Science
C. This is used to create
a file.
D. This is used to delete a
file.

You might also like