SlideShare a Scribd company logo
1 of 10
Download to read offline
Say whether each of the following statements is true (“T”) or false (“F”).
__ When modifying existing software, changes should follow the style of the original code.
__ In software testing, “path coverage” is another name for “statement coverage”.
__ The file command can be used to assess the type of a file.
__ The “o” in a pattern o+rx that can be given as as argument to chmod(1) stands for “owner”.
__ A downside to operating systems like LINUX and UNIX is that they still use the concept of
processes.
Other operating systems, such as Microsoft Windows, have done away with processes.
__ To send a signal to a process we use the >>> construct in the shell. For example, to send a
SIGKILL to a process with PID 7476, we would give the command
__ A characteristic of TDD (test-driven development) is the extensive use of prototypes.
__ Most UNIX/LINUX (shell) commands are actually the names of programs.
__ A characteristic of iterative software development is that one breaks a problem into a small
problem plus
a series of increments.
__ In a C/C++ program that includes the file , a data type of uint32_t is always 4 bytes in size.
B. (1 mark each, 6 marks total)
In each of the statements below, fill in the blank with the word or phrase which best fits the
overall state- ment.
In the context of output from ps(1), the acronym PPID stands for
_______________________________ .
The name of the environment variable which defines the list of paths searched by bash for
commands is
_________________________ .
Every complete C/C++ program has a function called __________________ . It is the standard
entry point
to the program.
UNIX/LINUX tools (commands) typically follow the convention of writing their output to
____________________________ and reading their input from __________________________
.
In UNIX/LINUX, a(n) _______________ is a named sequence of nonvolatile bytes.
A(n) _______________ is a a pair of streams, one for writing and one for reading, such that
everything written on the output stream can be read from the input stream in order and with full
fidelity.
C. (26 marks)
For each of the following multiple-choice1 questions, indicate the answer that is the best
response to the question. Circle the label (e.g. “(a)”) of your intended response in each case.
1. Which of the following sentences describing “testing” and “debugging” is true?
(a) Testing finds bugs, debugging locates error messages.
(b) Testing finds coding faults, debugging locates execution failures.
(c) Testing finds execution failures, debugging locates coding faults.
(d) Testing generates error messages, debugging locates bugs.
(e) None of the above.
1. or, as Peppermint Patty from the Peanuts comic strip would say, “mystical guess”
page 2
Cmpt 214 Midterm Examination
October 21, 2014
Which of the following statements regarding good programming style is true?
(a) A user should preferentially use the layout
rather than
(b) A user should preferentially use the layout if (condition)
{ }
rather than
(c) Either of
if (condition)
{ }
or
can be used. What is more important, however, is that one format is chosen and then used consis-
tently.
(d) Neither
if( condition ) {
}
nor
is an acceptable format.
What is the name of the type of testing that checks that features that were working before are still
work- ing?
(a) White-box testing.
(b) Unit testing.
(c) Regression testing.
(d) Randomized testing.
(e) None of the above.
The “#ifdef” construct in C/C++ is an example of
(a) a preprocessor directive.
(b) bad programming style.
(c) TDD.
(d) defensive programming.
(e) None of the above.
page 3
Cmpt 214 Midterm Examination
October 21, 2014
What is the name of a special file in UNIX/LINUX to which one can redirect output and that
output is simply discarded (by the operating system)?
(a) NULL
(b) /dev/null
(c) /root
(d) /usr/bin
(e) Any of the above.
page 4
Cmpt 214 Midterm Examination
October 21, 2014
Consider the following declaration in C:
Given the above, the address of student_records[2] will be the same as the value of which
expression below?
(a) student_records[0]+2
(b) *student_records[2]
(c) *student_records+2
(d) rec_p+2
(e) None of the above.
In a C/C++ program, writing if( 7 == N )
rather than
if( N == 7 )
is an example of what?
(a) Defensive programming.
(b) Iterative software development.
(c) Use of prototypes.
(d) Test-driven development.
(e) All of the above.
It is the job of the shell (e.g. bash) to interpret various components of a command. Which of the
following is(are) not interpreted by the shell?
(a) History references, such as !!.
(b) A command alias.
(c) Filename wildcards.
(d) Shell variable names preceded by $.
(e) Arguments enclosed within single quotes, ''.
(f) All of the above.
What is the function of the “>>” operator in the bash command cat foo >> bar
? Assume that the noclobber shell variable is set to its default value.
(a) Passes output of cat(1) to the program (command) bar.
(b) Indicates that data from the file bar should be considered (input) after the data from file foo.
(c) Overwrites file bar with the contents of file foo.
(d) Redirects error messages from the execution of cat into file foo.
(e) None of the above.
page 5
Cmpt 214 Midterm Examination
12. Consider the following sample of code from an in-class example.
October 21, 2014
}
The example was following the in-class programming guidelines and TDD. As such, it is an
example of
(a) defensive programming.
(b) a prototype.
(c) a data definition.
(d) a module template.
(e) a stub.
(f) None of the above.
13. Consider again the following sample of code from an in-class example.
}
The example was following the in-class programming guidelines and TDD. As such, the
return 'F';
statement is an example of
(a) defensive programming.
(b) a prototype.
(c) a data definition.
(d) a module template.
(e) a stub.
(f) None of the above.
14. An early version of UNIX was
(a) System III.
(b) System V.
(c) SunOS.
(d) 4.3BSD.
(e) All of the above.
page 6
Cmpt 214 Midterm Examination
October 21, 2014
Consider the following pipelined command:
cat < /etc/passwd | cut -f 3 | wc -l
Which of the following statements is false regarding this complex command?
(a) cut(1) gets its input from a pipe
(b) cut(1) gets its input from its standard input
(c) cat(1) gets its input from its standard input
(d) cat(1) is invoked with one command-line argument
(e) All of the above.
Which of the following commands below can be used to determine what file systems have been
mounted on a (running) LINUX/UNIX file system?
(a) df
(b) uname
(c) hostname
(d) whoami
(e) All of the above.
(f) None of the above.
Which of the following bash commands will produce the output $PATH
?
(a) echo $PATH
(b) echo "$PATH"
(c) echo $PATH
(d) cat $PATH
What is the role of “&” in the command sort foo.txt > bar.txt &
?
(a) It forces the overwriting of bar.txt, even if it already exists.
(b) It makes sure that the command completes.
(c) It directs the shell to run the sort process in the background.
(d) It forces the command to be run as a shell built-in.
(e) It tells the shell to execute the command without creating a child process.
(f) None of the above.
A co-worker suggests that worrying about permissions on a file-by-file basis is too much work,
and sug- gests setting the permissions of all files using
chmod 777
Which of the below represents a legitimate response?
(a) This is fine.
(b) Everyone would be able to access my files!
(c) I won't be able to access my own files!
(d) None of the above.
page 7
Cmpt 214 Midterm Examination
October 21, 2014
When input to the shell, the file pathname . (as in ./ ) is used to denote
(a) the user's home directory.
(b) the root directory of the file system.
(c) the current working directory.
(d) None of the above.
What is the name of that portion of the operating system which provides only the minimum of
services
necessary for implementing additional O/S services?
(a) X-Windows.
(b) The kernel.
(c) Root.
(d) A server.
(e) None of the above.
What type of entity can be organized according to “layers of abstraction”, where each layer
defines an abstract machine?
(a) A GUI-based windowing system.
(b) An operating system.
(c) Software designed using TDD.
(d) A testing scaffold.
(e) None of the above.
How many processes in total are created by the shell to execute the following complex
command? ls /etc/foobar ; date
(a) 1
(b) 2
(c) 3
(d) 4
(e) None of the above.
Which of the following commands can be used to search for all instances of the string
“TESTING” in all files in the current working directory whose names start with the string
“queen”, then contain a number between 0 and 99, and finally end with “.cc”.
(a) egrep TESTING 'queen[0-9][0-9]?.cc'
(b) egrep 'TESTING' queen[0-9].cc queen[0-9][0-9].cc
(c) egrep TESTING 'queen[0-9]{1,2}.cc'
(d) Any of the above.
What is the name of the “configuration file” for bash, a file of commands that are read and
executed by bash when it starts and prior to prompting the user for input?
(a) .bashrc
(b) login
(c) .login
(d) /etc/config
(e) None of the above.
page 8
Cmpt 214 Midterm Examination October 21, 2014
26. What is the name of a program that you can use to obtain online documentation on tuxworld?
(a) info
(b) man
(c) khelpcenter (d) All of the above.
D. (1 mark each, total 5 marks)
Consider the following LINUX commands (commands one could
give on a tuxworld machine via bash): ls
which whatis
whatis which
(a) ls -l
(b) ls -la
(c) df
(d) ps -u $USER
(e) du -s -m /usr/bin
(f) uptime
(g) (h) (i) (j) (k) (l)
Consider each portion of output below. Each was produced by one of the commands above. For
each portion of output, write the letter label of the command which produced that output.
1. ____
15:50:15 up 7 days, 1:39, 20 users, load average: 0.02, 0.02, 0.05
____ which []
____
PID TTY
____ total 18
5. ____ /usr/bin/whatis
E. (1 mark each, total 12 marks)
Suppose that the file phone_directory.txt contains the following lines of information. Each line
consists of 4 fields (columns) separated by single tab characters. The fields are obvious from
viewing the layout of the file when it is printed on a terminal:
page 9
Cmpt 214 Midterm Examination
October 21, 2014
A Hacker B Ator
C Reasoner D BitDiddle E Fect
F Tweakit
We will refer to the above lines in phone_directory.txt by the letters A through F to the left of
each line. For example, A refers the first line, while F refers to the final line. The labelling letters
are not part of the lines of text in the file.
Below are commands (given to bash) that operate on phone_directory.txt. The commands may
or may not produce any output. For each of the commands, enter the letter label (A–F) of the line
in the file phone_directory.txt which originally contained the text which is output first. That is,
for all the commands below, answer the question, “which of the above lines contains the text that
first appears in response to the command?” For example, if a command first yields a line
consisting of the text “Eva” from the second line in phone_directory.txt, you should enter “B” as
the answer to the question (reflecting the fact that this text came from line “B” of
phone_directory.txt). Additionally, if the command generates no output, enter “N”. Finally, if
none of the answers A–F or N is correct, enter “X” as indicating “None of the above”.
grep 't' phone_directory.txt
grep 't>' phone_directory.txt
egrep '[0-9]{3}-[01]{3}-[01]{4}$' phone_directory.txt
egrep '.A?' phone_directory.txt
egrep '(^w).*1' phone_directory.txt
egrep -v '^w+W+w+W+wW' phone_directory.txt
sort phone_directory.txt
cut -f 3 < phone_directory.txt | sort -r
cat <<< phone_directory.txt
rm -f a.txt; cat phone_directory.txt a.txt >b.txt 2>e.txt ; cat e.txt
rm -f a.txt; cat phone_directory.txt a.txt >b.txt 2>e.txt ; cat b.txt
sort phone_directory.txt > a.txt; date >> a.txt; cat a.txt
page 10
Cmpt 214 Midterm Examination October 21, 2014
F. (2+1+1+1+1+1+3 = 10 marks)
Answer each of the following questions with a technically-oriented answer. In some cases, a very
short, pre- cise answer is in order. In others, a concise descriptive answer is required.
A programmer would like to make use of the system library function printf(3). The programmer
knows that she will need to include a system “.h” file to be able to use printf(), but does not
know ex- actly which one. What LINUX/UNIX command should the programmer use to obtain
online information to determine the name of the system “.h” file to include? Give the complete
command.
What is the (shell) filename wild-card character that will match one, and only one, arbitrary
character?
What is the bash command involving the history buffer which causes the shell to repeat the
immediately
previous command?
The following fragment of C/C++ exhibits poor programming style. Why? What is wrong with
it?
The following fragment of C/C++ exhibits poor programming style. Why? What is wrong with
it?
}
Consider the following piece of code. It is intended to declare the State datatype according to the
pro- gramming guidelines given in class. Unfortunately, it does not in fact adhere to those
guidelines. Why? What is wrong with it?
Solution
1.Every complete C/C++ program has a function called main( ) function. It is the standard entry
point
to the program.
2. Which of the following statements regarding good programming style is true?
(a) A user should preferentially use the layout
rather than
3..The “#ifdef” construct in C/C++ is an example of a preprocessor directive.

More Related Content

Similar to Say whether each of the following statements is true (“T”) or false .pdf

COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxCOMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
donnajames55
 
Specialist marketing officer professional knowledge questions.pdf(1)
Specialist marketing officer professional knowledge questions.pdf(1)Specialist marketing officer professional knowledge questions.pdf(1)
Specialist marketing officer professional knowledge questions.pdf(1)
Nivi Mohanty
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02
Wei Sun
 
C programming session 11
C programming session 11C programming session 11
C programming session 11
Vivek Singh
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
Sami Said
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
Wei Sun
 
Debug tutorial
Debug tutorialDebug tutorial
Debug tutorial
Defri N
 
Black hat 2010-bannedit-advanced-command-injection-exploitation-1-wp
Black hat 2010-bannedit-advanced-command-injection-exploitation-1-wpBlack hat 2010-bannedit-advanced-command-injection-exploitation-1-wp
Black hat 2010-bannedit-advanced-command-injection-exploitation-1-wp
rgster
 
CSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docxCSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docx
mydrynan
 
5.Shell And Environment
5.Shell And Environment5.Shell And Environment
5.Shell And Environment
phanleson
 

Similar to Say whether each of the following statements is true (“T”) or false .pdf (20)

cs262_intro_slides.pptx
cs262_intro_slides.pptxcs262_intro_slides.pptx
cs262_intro_slides.pptx
 
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxCOMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
 
Specialist marketing officer professional knowledge questions.pdf(1)
Specialist marketing officer professional knowledge questions.pdf(1)Specialist marketing officer professional knowledge questions.pdf(1)
Specialist marketing officer professional knowledge questions.pdf(1)
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
POS 433 Effective Communication - tutorialrank.com
POS 433 Effective Communication - tutorialrank.comPOS 433 Effective Communication - tutorialrank.com
POS 433 Effective Communication - tutorialrank.com
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02
 
C programming session 11
C programming session 11C programming session 11
C programming session 11
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Debug tutorial
Debug tutorialDebug tutorial
Debug tutorial
 
Black hat 2010-bannedit-advanced-command-injection-exploitation-1-wp
Black hat 2010-bannedit-advanced-command-injection-exploitation-1-wpBlack hat 2010-bannedit-advanced-command-injection-exploitation-1-wp
Black hat 2010-bannedit-advanced-command-injection-exploitation-1-wp
 
02 c++g3 d
02 c++g3 d02 c++g3 d
02 c++g3 d
 
Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008
 
CSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docxCSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docx
 
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERSVTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
 
5.Shell And Environment
5.Shell And Environment5.Shell And Environment
5.Shell And Environment
 

More from RBMADU

Between 2000 and 2002, then again from 2008 to 2010, access measures.pdf
Between 2000 and 2002, then again from 2008 to 2010, access measures.pdfBetween 2000 and 2002, then again from 2008 to 2010, access measures.pdf
Between 2000 and 2002, then again from 2008 to 2010, access measures.pdf
RBMADU
 
using the single linked list code written in the class or in the lab,.pdf
using the single linked list code written in the class or in the lab,.pdfusing the single linked list code written in the class or in the lab,.pdf
using the single linked list code written in the class or in the lab,.pdf
RBMADU
 
A database management system is also referred to as a database. True.pdf
A database management system is also referred to as a database.  True.pdfA database management system is also referred to as a database.  True.pdf
A database management system is also referred to as a database. True.pdf
RBMADU
 
The fundamental theory of electromagnetic field is based on Maxwell.pdf
The fundamental theory of electromagnetic field is based on Maxwell.pdfThe fundamental theory of electromagnetic field is based on Maxwell.pdf
The fundamental theory of electromagnetic field is based on Maxwell.pdf
RBMADU
 
Part I – Antibiotics and the Human Microbiome Amelia and her family .pdf
Part I – Antibiotics and the Human Microbiome Amelia and her family .pdfPart I – Antibiotics and the Human Microbiome Amelia and her family .pdf
Part I – Antibiotics and the Human Microbiome Amelia and her family .pdf
RBMADU
 
Since somathesthetic sensation from each side of the body projects t.pdf
Since somathesthetic sensation from each side of the body projects t.pdfSince somathesthetic sensation from each side of the body projects t.pdf
Since somathesthetic sensation from each side of the body projects t.pdf
RBMADU
 
Research and identify three IT-related Risk Management Plans and lis.pdf
Research and identify three IT-related Risk Management Plans and lis.pdfResearch and identify three IT-related Risk Management Plans and lis.pdf
Research and identify three IT-related Risk Management Plans and lis.pdf
RBMADU
 
please help me with two partI Bold it out as wrong part which in t.pdf
please help me with two partI Bold it out as wrong part which in t.pdfplease help me with two partI Bold it out as wrong part which in t.pdf
please help me with two partI Bold it out as wrong part which in t.pdf
RBMADU
 
Network peering is a method to save ISP’s network bandwidth and reso.pdf
Network peering is a method to save ISP’s network bandwidth and reso.pdfNetwork peering is a method to save ISP’s network bandwidth and reso.pdf
Network peering is a method to save ISP’s network bandwidth and reso.pdf
RBMADU
 

More from RBMADU (20)

Between 2000 and 2002, then again from 2008 to 2010, access measures.pdf
Between 2000 and 2002, then again from 2008 to 2010, access measures.pdfBetween 2000 and 2002, then again from 2008 to 2010, access measures.pdf
Between 2000 and 2002, then again from 2008 to 2010, access measures.pdf
 
Below is a diagram of the coding strand of DNA showing a gene please .pdf
Below is a diagram of the coding strand of DNA showing a gene please .pdfBelow is a diagram of the coding strand of DNA showing a gene please .pdf
Below is a diagram of the coding strand of DNA showing a gene please .pdf
 
A patient has a tidal volume of 0.50 L, a frequency of breathing or r.pdf
A patient has a tidal volume of 0.50 L, a frequency of breathing or r.pdfA patient has a tidal volume of 0.50 L, a frequency of breathing or r.pdf
A patient has a tidal volume of 0.50 L, a frequency of breathing or r.pdf
 
Write a program to recognizing Idenifier Or Constant in C language.pdf
Write a program to recognizing Idenifier Or Constant in C language.pdfWrite a program to recognizing Idenifier Or Constant in C language.pdf
Write a program to recognizing Idenifier Or Constant in C language.pdf
 
Why having a lipid rich cell wall make a bacteria harder to stain.pdf
Why having a lipid rich cell wall make a bacteria harder to stain.pdfWhy having a lipid rich cell wall make a bacteria harder to stain.pdf
Why having a lipid rich cell wall make a bacteria harder to stain.pdf
 
Which of the following statements about leasing is falseALease fina.pdf
Which of the following statements about leasing is falseALease fina.pdfWhich of the following statements about leasing is falseALease fina.pdf
Which of the following statements about leasing is falseALease fina.pdf
 
using the single linked list code written in the class or in the lab,.pdf
using the single linked list code written in the class or in the lab,.pdfusing the single linked list code written in the class or in the lab,.pdf
using the single linked list code written in the class or in the lab,.pdf
 
A database management system is also referred to as a database. True.pdf
A database management system is also referred to as a database.  True.pdfA database management system is also referred to as a database.  True.pdf
A database management system is also referred to as a database. True.pdf
 
An envolope contains three cards A black card that is black on both.pdf
An envolope contains three cards A black card that is black on both.pdfAn envolope contains three cards A black card that is black on both.pdf
An envolope contains three cards A black card that is black on both.pdf
 
There was a mass extinction of plants and animals at the end of the P.pdf
There was a mass extinction of plants and animals at the end of the P.pdfThere was a mass extinction of plants and animals at the end of the P.pdf
There was a mass extinction of plants and animals at the end of the P.pdf
 
The size P of a certain insect population at time t (in days) obeys t.pdf
The size P of a certain insect population at time t (in days) obeys t.pdfThe size P of a certain insect population at time t (in days) obeys t.pdf
The size P of a certain insect population at time t (in days) obeys t.pdf
 
The fundamental theory of electromagnetic field is based on Maxwell.pdf
The fundamental theory of electromagnetic field is based on Maxwell.pdfThe fundamental theory of electromagnetic field is based on Maxwell.pdf
The fundamental theory of electromagnetic field is based on Maxwell.pdf
 
Part I – Antibiotics and the Human Microbiome Amelia and her family .pdf
Part I – Antibiotics and the Human Microbiome Amelia and her family .pdfPart I – Antibiotics and the Human Microbiome Amelia and her family .pdf
Part I – Antibiotics and the Human Microbiome Amelia and her family .pdf
 
Recall the Squeeze TheoremSuppose that for all n, xn yn zn. If .pdf
Recall the Squeeze TheoremSuppose that for all n, xn  yn  zn. If .pdfRecall the Squeeze TheoremSuppose that for all n, xn  yn  zn. If .pdf
Recall the Squeeze TheoremSuppose that for all n, xn yn zn. If .pdf
 
Since somathesthetic sensation from each side of the body projects t.pdf
Since somathesthetic sensation from each side of the body projects t.pdfSince somathesthetic sensation from each side of the body projects t.pdf
Since somathesthetic sensation from each side of the body projects t.pdf
 
Research and identify three IT-related Risk Management Plans and lis.pdf
Research and identify three IT-related Risk Management Plans and lis.pdfResearch and identify three IT-related Risk Management Plans and lis.pdf
Research and identify three IT-related Risk Management Plans and lis.pdf
 
please help me with two partI Bold it out as wrong part which in t.pdf
please help me with two partI Bold it out as wrong part which in t.pdfplease help me with two partI Bold it out as wrong part which in t.pdf
please help me with two partI Bold it out as wrong part which in t.pdf
 
Matching. Choose the most appropriate answer from the right. 1. Null .pdf
Matching. Choose the most appropriate answer from the right. 1. Null .pdfMatching. Choose the most appropriate answer from the right. 1. Null .pdf
Matching. Choose the most appropriate answer from the right. 1. Null .pdf
 
Numerous diseases are caused by viruses and bacteria (etc. Hepatitis.pdf
Numerous diseases are caused by viruses and bacteria (etc. Hepatitis.pdfNumerous diseases are caused by viruses and bacteria (etc. Hepatitis.pdf
Numerous diseases are caused by viruses and bacteria (etc. Hepatitis.pdf
 
Network peering is a method to save ISP’s network bandwidth and reso.pdf
Network peering is a method to save ISP’s network bandwidth and reso.pdfNetwork peering is a method to save ISP’s network bandwidth and reso.pdf
Network peering is a method to save ISP’s network bandwidth and reso.pdf
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 

Say whether each of the following statements is true (“T”) or false .pdf

  • 1. Say whether each of the following statements is true (“T”) or false (“F”). __ When modifying existing software, changes should follow the style of the original code. __ In software testing, “path coverage” is another name for “statement coverage”. __ The file command can be used to assess the type of a file. __ The “o” in a pattern o+rx that can be given as as argument to chmod(1) stands for “owner”. __ A downside to operating systems like LINUX and UNIX is that they still use the concept of processes. Other operating systems, such as Microsoft Windows, have done away with processes. __ To send a signal to a process we use the >>> construct in the shell. For example, to send a SIGKILL to a process with PID 7476, we would give the command __ A characteristic of TDD (test-driven development) is the extensive use of prototypes. __ Most UNIX/LINUX (shell) commands are actually the names of programs. __ A characteristic of iterative software development is that one breaks a problem into a small problem plus a series of increments. __ In a C/C++ program that includes the file , a data type of uint32_t is always 4 bytes in size. B. (1 mark each, 6 marks total) In each of the statements below, fill in the blank with the word or phrase which best fits the overall state- ment. In the context of output from ps(1), the acronym PPID stands for _______________________________ . The name of the environment variable which defines the list of paths searched by bash for commands is _________________________ . Every complete C/C++ program has a function called __________________ . It is the standard entry point to the program. UNIX/LINUX tools (commands) typically follow the convention of writing their output to ____________________________ and reading their input from __________________________ . In UNIX/LINUX, a(n) _______________ is a named sequence of nonvolatile bytes. A(n) _______________ is a a pair of streams, one for writing and one for reading, such that everything written on the output stream can be read from the input stream in order and with full fidelity. C. (26 marks)
  • 2. For each of the following multiple-choice1 questions, indicate the answer that is the best response to the question. Circle the label (e.g. “(a)”) of your intended response in each case. 1. Which of the following sentences describing “testing” and “debugging” is true? (a) Testing finds bugs, debugging locates error messages. (b) Testing finds coding faults, debugging locates execution failures. (c) Testing finds execution failures, debugging locates coding faults. (d) Testing generates error messages, debugging locates bugs. (e) None of the above. 1. or, as Peppermint Patty from the Peanuts comic strip would say, “mystical guess” page 2 Cmpt 214 Midterm Examination October 21, 2014 Which of the following statements regarding good programming style is true? (a) A user should preferentially use the layout rather than (b) A user should preferentially use the layout if (condition) { } rather than (c) Either of if (condition) { } or can be used. What is more important, however, is that one format is chosen and then used consis- tently. (d) Neither if( condition ) { } nor is an acceptable format. What is the name of the type of testing that checks that features that were working before are still work- ing? (a) White-box testing. (b) Unit testing. (c) Regression testing. (d) Randomized testing. (e) None of the above.
  • 3. The “#ifdef” construct in C/C++ is an example of (a) a preprocessor directive. (b) bad programming style. (c) TDD. (d) defensive programming. (e) None of the above. page 3 Cmpt 214 Midterm Examination October 21, 2014 What is the name of a special file in UNIX/LINUX to which one can redirect output and that output is simply discarded (by the operating system)? (a) NULL (b) /dev/null (c) /root (d) /usr/bin (e) Any of the above. page 4 Cmpt 214 Midterm Examination October 21, 2014 Consider the following declaration in C: Given the above, the address of student_records[2] will be the same as the value of which expression below? (a) student_records[0]+2 (b) *student_records[2] (c) *student_records+2 (d) rec_p+2 (e) None of the above. In a C/C++ program, writing if( 7 == N ) rather than if( N == 7 ) is an example of what? (a) Defensive programming. (b) Iterative software development. (c) Use of prototypes. (d) Test-driven development. (e) All of the above.
  • 4. It is the job of the shell (e.g. bash) to interpret various components of a command. Which of the following is(are) not interpreted by the shell? (a) History references, such as !!. (b) A command alias. (c) Filename wildcards. (d) Shell variable names preceded by $. (e) Arguments enclosed within single quotes, ''. (f) All of the above. What is the function of the “>>” operator in the bash command cat foo >> bar ? Assume that the noclobber shell variable is set to its default value. (a) Passes output of cat(1) to the program (command) bar. (b) Indicates that data from the file bar should be considered (input) after the data from file foo. (c) Overwrites file bar with the contents of file foo. (d) Redirects error messages from the execution of cat into file foo. (e) None of the above. page 5 Cmpt 214 Midterm Examination 12. Consider the following sample of code from an in-class example. October 21, 2014 } The example was following the in-class programming guidelines and TDD. As such, it is an example of (a) defensive programming. (b) a prototype. (c) a data definition. (d) a module template. (e) a stub. (f) None of the above. 13. Consider again the following sample of code from an in-class example. } The example was following the in-class programming guidelines and TDD. As such, the return 'F'; statement is an example of (a) defensive programming. (b) a prototype. (c) a data definition.
  • 5. (d) a module template. (e) a stub. (f) None of the above. 14. An early version of UNIX was (a) System III. (b) System V. (c) SunOS. (d) 4.3BSD. (e) All of the above. page 6 Cmpt 214 Midterm Examination October 21, 2014 Consider the following pipelined command: cat < /etc/passwd | cut -f 3 | wc -l Which of the following statements is false regarding this complex command? (a) cut(1) gets its input from a pipe (b) cut(1) gets its input from its standard input (c) cat(1) gets its input from its standard input (d) cat(1) is invoked with one command-line argument (e) All of the above. Which of the following commands below can be used to determine what file systems have been mounted on a (running) LINUX/UNIX file system? (a) df (b) uname (c) hostname (d) whoami (e) All of the above. (f) None of the above. Which of the following bash commands will produce the output $PATH ? (a) echo $PATH (b) echo "$PATH" (c) echo $PATH (d) cat $PATH What is the role of “&” in the command sort foo.txt > bar.txt & ?
  • 6. (a) It forces the overwriting of bar.txt, even if it already exists. (b) It makes sure that the command completes. (c) It directs the shell to run the sort process in the background. (d) It forces the command to be run as a shell built-in. (e) It tells the shell to execute the command without creating a child process. (f) None of the above. A co-worker suggests that worrying about permissions on a file-by-file basis is too much work, and sug- gests setting the permissions of all files using chmod 777 Which of the below represents a legitimate response? (a) This is fine. (b) Everyone would be able to access my files! (c) I won't be able to access my own files! (d) None of the above. page 7 Cmpt 214 Midterm Examination October 21, 2014 When input to the shell, the file pathname . (as in ./ ) is used to denote (a) the user's home directory. (b) the root directory of the file system. (c) the current working directory. (d) None of the above. What is the name of that portion of the operating system which provides only the minimum of services necessary for implementing additional O/S services? (a) X-Windows. (b) The kernel. (c) Root. (d) A server. (e) None of the above. What type of entity can be organized according to “layers of abstraction”, where each layer defines an abstract machine? (a) A GUI-based windowing system. (b) An operating system. (c) Software designed using TDD. (d) A testing scaffold.
  • 7. (e) None of the above. How many processes in total are created by the shell to execute the following complex command? ls /etc/foobar ; date (a) 1 (b) 2 (c) 3 (d) 4 (e) None of the above. Which of the following commands can be used to search for all instances of the string “TESTING” in all files in the current working directory whose names start with the string “queen”, then contain a number between 0 and 99, and finally end with “.cc”. (a) egrep TESTING 'queen[0-9][0-9]?.cc' (b) egrep 'TESTING' queen[0-9].cc queen[0-9][0-9].cc (c) egrep TESTING 'queen[0-9]{1,2}.cc' (d) Any of the above. What is the name of the “configuration file” for bash, a file of commands that are read and executed by bash when it starts and prior to prompting the user for input? (a) .bashrc (b) login (c) .login (d) /etc/config (e) None of the above. page 8 Cmpt 214 Midterm Examination October 21, 2014 26. What is the name of a program that you can use to obtain online documentation on tuxworld? (a) info (b) man (c) khelpcenter (d) All of the above. D. (1 mark each, total 5 marks) Consider the following LINUX commands (commands one could give on a tuxworld machine via bash): ls which whatis whatis which (a) ls -l (b) ls -la (c) df
  • 8. (d) ps -u $USER (e) du -s -m /usr/bin (f) uptime (g) (h) (i) (j) (k) (l) Consider each portion of output below. Each was produced by one of the commands above. For each portion of output, write the letter label of the command which produced that output. 1. ____ 15:50:15 up 7 days, 1:39, 20 users, load average: 0.02, 0.02, 0.05 ____ which [] ____ PID TTY ____ total 18 5. ____ /usr/bin/whatis E. (1 mark each, total 12 marks) Suppose that the file phone_directory.txt contains the following lines of information. Each line consists of 4 fields (columns) separated by single tab characters. The fields are obvious from viewing the layout of the file when it is printed on a terminal: page 9 Cmpt 214 Midterm Examination October 21, 2014 A Hacker B Ator C Reasoner D BitDiddle E Fect F Tweakit We will refer to the above lines in phone_directory.txt by the letters A through F to the left of each line. For example, A refers the first line, while F refers to the final line. The labelling letters are not part of the lines of text in the file. Below are commands (given to bash) that operate on phone_directory.txt. The commands may or may not produce any output. For each of the commands, enter the letter label (A–F) of the line in the file phone_directory.txt which originally contained the text which is output first. That is, for all the commands below, answer the question, “which of the above lines contains the text that first appears in response to the command?” For example, if a command first yields a line consisting of the text “Eva” from the second line in phone_directory.txt, you should enter “B” as the answer to the question (reflecting the fact that this text came from line “B” of phone_directory.txt). Additionally, if the command generates no output, enter “N”. Finally, if none of the answers A–F or N is correct, enter “X” as indicating “None of the above”. grep 't' phone_directory.txt
  • 9. grep 't>' phone_directory.txt egrep '[0-9]{3}-[01]{3}-[01]{4}$' phone_directory.txt egrep '.A?' phone_directory.txt egrep '(^w).*1' phone_directory.txt egrep -v '^w+W+w+W+wW' phone_directory.txt sort phone_directory.txt cut -f 3 < phone_directory.txt | sort -r cat <<< phone_directory.txt rm -f a.txt; cat phone_directory.txt a.txt >b.txt 2>e.txt ; cat e.txt rm -f a.txt; cat phone_directory.txt a.txt >b.txt 2>e.txt ; cat b.txt sort phone_directory.txt > a.txt; date >> a.txt; cat a.txt page 10 Cmpt 214 Midterm Examination October 21, 2014 F. (2+1+1+1+1+1+3 = 10 marks) Answer each of the following questions with a technically-oriented answer. In some cases, a very short, pre- cise answer is in order. In others, a concise descriptive answer is required. A programmer would like to make use of the system library function printf(3). The programmer knows that she will need to include a system “.h” file to be able to use printf(), but does not know ex- actly which one. What LINUX/UNIX command should the programmer use to obtain online information to determine the name of the system “.h” file to include? Give the complete command. What is the (shell) filename wild-card character that will match one, and only one, arbitrary character? What is the bash command involving the history buffer which causes the shell to repeat the immediately previous command? The following fragment of C/C++ exhibits poor programming style. Why? What is wrong with it? The following fragment of C/C++ exhibits poor programming style. Why? What is wrong with it? } Consider the following piece of code. It is intended to declare the State datatype according to the pro- gramming guidelines given in class. Unfortunately, it does not in fact adhere to those guidelines. Why? What is wrong with it? Solution
  • 10. 1.Every complete C/C++ program has a function called main( ) function. It is the standard entry point to the program. 2. Which of the following statements regarding good programming style is true? (a) A user should preferentially use the layout rather than 3..The “#ifdef” construct in C/C++ is an example of a preprocessor directive.