CS332 Final Exam 2023
False
"Make" recompiles all source files all the time to make sure the latest changes implemented correctly a. True b. False
False
A Makefile is created by typing the make command. a. True b. False
True
A shell is an interface between the user and the kernel. a. True b. False
lstat("text.in", &buf);
Assume input.txt is a regular file and text.in is a symbolic link to the file input.txt. Which of the following system calls return the information about the text.in file? A. lstat("input.txt", &buf) B. lstat("text.in", &buf); C. stat("input.txt", &buf); D. Stat(text. In", & Buf);
False
Converting a variable from an int to a float will never affect its nature a. True b. False
True
Deadlock occurs when a set of processes either compete for system resources or communicate with each other. A. True B. False
True
Every process has its own process counter A. True B. False
Brings the first process in the list to the foreground.
What is the role of the following command? fg %1 A. Waits the child process for 1 second B. Reduces the processor power 1 percent C. Brings the first process in a the list to the foreground D. Suspends the execution of the process whose id is 1
int
What type does the 'read' functions return value have? a. Boolean b. String c. Pointer d. int
Error
What will be the output of the following code? #include <stdio.h> main() { int *p; float a = 10.2; *p = a; printf("%d", *p); } a. 10 b. Error c. 10.2 d. Memory address of 'a'
4
What will be the output of the following program? int main() { int i = 5, j = 10, k = 15; printf("%d", sizeof(k /= i + j)); return 0; } a. 1 b. 13 c. 4 d. 15
Runtime Error
What will be the output of the following program? #include <stdio.h> int main() { const int i = 0; printf("%d\n", i++); return 0; } a. Return Error b. 0 c. 1 d. -1
1
What will be the output of the following program? int main(){ int x, y = 15, z = 15; x = y == z; printf("%d", x); return 0; }
Cache
When a program is loaded into the memory and it becomes a process. It can be divided into four sections. Which of the following is not part of these sections? A. Cache B. Data C. Heap D. Stack
If the fork() call is successful, then it returns 0 to the parent process.
Which one of the following statements is not true? A. If the fork() call is successful, then a unique process ID will be assigned to the child process. B. The calling process is referred to as the parent process C. If the fork() call is successful, then it returns 0 to the parent process. D. fork() creates a new process by duplicating the calling process
'> filename' notation will be used to append the file
Which one of the following systems is not True about I/O Redirection? A. '> filename' notation will be used to append the file B. '> filename' notation will be used for input redirection C. '> filename' notation will be used output redirection D. Regular unix system commands take input from the terminal
Init
Which process is the parent of all processes in the Linux environment? A. Father B. Mother C. Init D. Object
Stdio.h
Which standard library includes the printf($) and scanf() functions? a. stdlib.h b. stdio.h c. scanner.h d. time.h
Jobs
You can display various processes that are currently running in the background using the ____ A. Bg B. Jobs C. Ls D. Displaybg
&
You can execute a program in the background by typing the program name followed by the symbol ____ at the end. A. | B. # C. & D. >>
File descriptor
_____ is a non-negative integer number that uniquely identifies an open file in UNIX a. permission mode b. file descriptor c. buffer d. struct stat
atoi
______ converts a string to an integer. A. itoa B. atof C. atoi D. strToInt
lseek()
_______ is a system that is used to change the location of the read/write pointer of a file descriptor a. lseek() b. lstat() c. dirent() d. pointat()
NULL
________ is used to indicate that the pointer doesn't point to a valid location. A. Free B. Vacant C. Void D. Null
Gets
__________ keeps on reading until it sees a newline character. Thus, it is sensitive to Buffer Overflow attacks. A. fscanf B. fgets C. gets D. fopen
Compiler
gcc is a ______________ a. compiler b. interpreter c. assembler d. debugger
i will be converted to double
short int i; double d; Which of the following is True about d=d+i? a. This operation can't be performed b. i will be converted to double c. the result will be truncated d. d will be converted to int
True
Members of a structure are stored at different addresses, while the members of a union are stored at same address. a. True b. False
True
The size of a char point is equal to the size of an integer pointer a. True b. False
False
The statement "int a[6][5];" will create an array with 6 columns and 5 rows A. True B. False
False
The stringSplit function breaks a string into a sequence of zero or more nonempty tokens. A. True B. False
True
Bash is a type of of UNIX shell a. True b. False
False
Caching is the ability of an Os to support multiple, concurrent paths of execution within a single process. A. True B. False
False
If the fork() is successful, the in returns zero to the parent process and returns the process ID of the parents process to the child process. A. True B. False
False
If there is an error opening a file, the open function returns 1. a. True b. False
Static
In ___________ Memory Allocation, the memory is allocated from the stack. a. Dynamic b. Symbolic c. Static d. Bash
Opens a file for reading or writing
In systems programming, what does the open function do in C? A. Opens a file for reading or writing B. Opens a network socket C. Opens a newly mounted flash drive D. Opens a background process
True
Linux shell supports the pipes and we use | symbol to create a pipe between two processes. A. True B. False
Data
Global variables are stored in the ______ section A. Data B. Text C. Heap D. Stack
50
How many integers can be stored in the 2D array of "int arr[10][5]"? a. 32 b. 45 c. 15 d. 50
Kernel
The ____ is the heart of the operating system. It interacts with the hardware and most of the tasks like memory management, task scheduling, and file management. a. bash b. compiler c. shell d. kernel
strtok
The ______ function breaks a string into a sequence of zero or more nonempty tokens. On the first call, the string to be parsed should be specified in str. In each subsequent call that should parse the same string, str must be NULL. A. strtok B. strseq C. strparse D. strbreak
True
The c library function char *gets(char *str) reads a line from stdin and stores it into the string pointed to by str. A. True B. False
True
The close function returns zero on success and -1 on error. a. True b. False
True
The exec() family of functions replaces the current process image with a new process image. A. True B. False
False
The heap part of the memory stores the static variables. A. True B. False
True
The parent process could wait for the child process to terminate using the wait() function. A. True B. False
True
The proc file system (procfs) is a virtual file system that is created by the OS at system boot time to provide an interface between the kernel space and user space. A. True B. False
False
To display the full details of the running process we should use ls -f command. A. True B. False
False
Unix peripherals like hard drives, CD-ROMs, printers are considered drives. a. True b. False
True
User processes in a Linux environment could be in one of the following three states: foreground, background, or suspended. A. True B. False
0 1 2
What are the integer values corresponding to the standard input (stdin), standard output (stout), and standard error(stderr) respectively? a. 1 2 3 b. 0 1 2 c. 1 3 2 d. -1 -2 -3
Touch
Which Unix command can be used to create an empty text file if it does not exist? a. head b. touch c. makedir d. cat
cat
Which command can be used to display the contents of a file on the screen? A. Dog B. Top C. Ls D. Cat
Man
Which commands to use for compete details of a command on the shell? A. Readme B. Man C. Info D. Help
char str[4] = "abc";
Which is the correct way to define a string in C? a. char str[4] = "abc"; b. char str[3] = "abc"; c. string str[3] = "abc"; d. string str = "abc";
None of these
Which of the following best describes the C programming language? a. none of those b. object oriented programming c. procedural programming language d. scripting language
Preprocessor commands
Which of the following best describes the code below: #include <stdio.h> a. function declaration b. optimization parameter c. pointer d. Preprocessor commands
chmod
Which of the following commands can be used to change the default permissions for files and directories at the time of the creation? a. lseek b. chmod c. change d. chperm
execvpe
Which of the following functions takes the arguments as a vector? A. execle B. execl C. execvpe D. execlp
Tester
Which of the following is NOT a part of the compilation system? a. Linker b. Tester c. Preprocessor d. Assembler
'> filename' notation will be used to append the file
Which of the following is NOT true about I/O Redirection? a. '> filename' notation will be used for input redirection b. regular UNIX system command take input from the terminal (stdin) c. '> filename' notation will be used for output redirection d. '> filename' notation will be used to append the file
*a will give the address of the int a.
Which of the following is NOT true about pointers? a. *a will give the address of int a b. It is possible to create a pointer of pointer. c. to reach the memory location of variables, arrays, etc., use an ampersand (&) operator. d. the * and & operations cancel each other when used
The ~ character alone denotes the root is the filesystem tree
Which of the following is NOT true? a. all files are organized into directories b. all data are organized into files c. the ~ character alone denotes the root of the filesystem tree d. each file is uniquely identified by the inode number
A "do-while" loop is always executed at least once.
Which of the following is TRUE about the loops in C language? a. a "for" loop is faster than a "do-while" loop b. a "do-while" loop is always executed at least once c. a "while" loop is always executed at least once d. a "continue" statement can't be used in a "do-while" loop
The heap segment is used for a dynamic memory allocation
Which of the following is True about the memory blocks? a. the stack segment is used to store the program code b. the code segment is used to store the global variables c. the heap segment is used for dynamic memory allocation d. the data segment is used to store the functions data such as local variables
SEEK_BEG
Which of the following is an invalid constant when used in the lseek() function as 'whence' reference a. SEEK_END b. SEEK_SET c. SEEK_CUR d. SEEK_BEG
Condition codes
Which of the following is not an element of a process? A. State B. Program counter C. Identifier D. Condition codes
*
Which of the following operators can be used to access the value at the address stored in a pointer variable? A. || B. && C. * D. >>
*
Which of the following operators can be used to access the value at the address stored in a pointer variable? a. * b. && c. || d. >>
Underground
Which of the following state is does not exist for the Linux environment processes? A. Suspended B. Background C. Foreground D. Underground
drwxr——x
Which one of the following describes the directory permission below: Owner: read write execute permission Group: read permission World: execute permission a. drwxr——x b. -rwxr-x—x c. drwxr-x—x d. rwxr—wx
