Midterm1 Polling Questions 1-6 Flashcards
Lectures 1-6
Which of the following statements concerning open source operating systems is true?
- Solaris is open source
- Source code is freely available to read
- they are always more secure than commercial, closed systems
- all open source operating systems share the same set of goals
Source code is freely available to read
Which of the following operating systems is not opern source?
- Windows
- BSD UNIX
- Linux
- PCLinuxOS
Windows
A ____ is a custom build of the linux operating system
- LiveCD
- Installation
- Distribution
- VMWare Player
Distribution
Operating System
- Is a collection of programs
- provies user-interface
- is a resource manager
- all of the above
- none of the above
All of the Above
The Operating System kernel consists of all system and application programs in a computer
False
The operating system model consists of..
- a kernel layer, service layer, and user interface layer
- hardware layer, and software layer
- multitasking, time sharing, and multiuser
- system layer, utility layer, and appliation layer
- none of the above
a kernel layer , service layer, and user interface layer
The Kernel Layer manages all the hardware dependent functions
True of False?
True
What would a computer without an operating system be like?
- the software applications you wrote couldn’t send requests to the hardware through standard APIs
- there would only be one program running at a time and exiting
- there would be no graphical user interface
- all of these
All of These
An OS should be able to handle interrputs or signals that are triggered by either hardware or software
True of False?
True
In a C program a mandatory main() function is the start of the execution
True or False?
True
“#include<stdio.h>"in a progarm means</stdio.h>
- Include header files in code before compilation
- Stdio is a predefined standard library of functions under a system path
- contains function definitions that may be called in this file
- all of the above
All of the above
include “mylib.h” in a C program means
- incllude header files in code before compilation
- mylib is a user defined library of functinos under this directory
- contains function definitions that may be called in this file
- all of the above
all of the above
define in a C program may be
- constant
- preprocessor directive
- replaced by preprocessor in code before compilation
- all of the above
all of the above
An operating system is far easier to port to move to some other hardware if it is written in a lower level language(like assembly)
False
Indicate whether the expression evaluates to true or false. Let x = 7, y = 9.
NOT ( (x > 5) AND (y < 20) )
true or false?
False
Given numPeople = 10, userKey = ‘q’. Indicate whether the expression evaluates to true or false.
(numPeople >= 10) && (userKey == ‘x’)
False
Given numPeople = 10. Indicate whether the expression evaluates to true or false.
!( (numPeople == 5) || (numPeople == 6) )
True
Which operator is evaluated first in C?
w + 3 > x - y * z
*
Unary operators, like ! ++ –, have a higher priority than % * / + -.
In what order are the operators evaluated?
w + 3 != y - 1 && x
a) +, !=, -, &&
b) +, -, &&, !=
c) +, -, !=, &&
c) +, -, !=, &&
To what does this expression evaluate, given int x = 4, int y = 7.
x == 3 || x + 1 > y => (x == 3) || ((x + 1) > y )
A) True(1)
B) False(0)
False: B (x == 3) || ((x + 1) > y)
Which illustrates the actual order of evaluation via parentheses?
! green == red
(!green) == red
!(green == red)
(!green =)= red
(!green) == red
Which illustrates the actual order of evaluation via parentheses?
bats < birds || birds < insects
((bats < birds) || birds) < insects
bats < (birds || birds) < insects
(bats < birds) || (birds < insects)
C-> (bats < birds) || (birds < insects)
Which illustrates the actual order of evaluation via parentheses?
! (bats < birds) || (birds < insects)
! ((bats < birds) || (birds < insects))
(! (bats < birds)) || (birds < insects)
((!bats) < birds) || (birds < insects)
(! (bats < birds)) || (birds < insects)
Which illustrates the actual order of evaluation via parentheses?
(num1 == 9) || (num2 == 0) && (num3 == 0)
(num1 == 9) || ((num2 == 0) && (num3 == 0))
((num1 == 9) || (num2 == 0)) && (num3 == 0)
(num1 == 9) || (num2 == (0 && num3) == 0)
(((num1 == (9 || num2) == 0) && num3) == 0)
(num1 == 9) || ((num2 == 0) && (num3 == 0))
If age == 28, then what does this evaluate to?
(16 < age < 25)
True(16<28)
How to fix this expression to work as the programmer intended?
(16 < age < 25)
A) (16 < age) && (age < 25)
B) (16 < age) || (age < 25)
C) (16 < age) & (age < 25)
D) (25 > age > 16)
A
Given the following code, how many times will the inner loop body execute?
int row;
int col;
for(row = 0; row < 2; row = row + 1) {
for(col = 0; col < 3; col = col + 1) {
// Inner loop body
}
}
A) 6 C) 18
B) 3 D) 5
A
What is the value of j after the fourth loop?
int j = 0;
for (int i = 0; i < 5; ++i) {
j = j * i;
}
A) 4 C) 64
B) 0 D) 128
B
After the loop terminates can j be printed out (with printf)?
for (int i = 0; i < 5; ++i) {
int j = 0;
j = j * i;
}
Yes
No
NO
What will this code output?
#include<stdio.h>
int main()
{
int n;
for(n = 7; n!=0; n--)
printf("n = %d", n--);
getchar();
return 0;
}</stdio.h>
Infinite loop since n==0 is not satisfied during the for loop
n = 0
n = 1
n = 2
Infinite loop since n==0….
only the printf is
executed in for loop
No brackets! {…} means
n is…
7 compared to 0
6 and 5
5 compared to 0
4 and 3
3 compared to 0
2 and 1
1 compared to 0
0 and -1
-1 compared to 0
Fix with n>=0.
These two loops (left and right) produce the same thing
#include<stdio.h>
int main()
{
int i = 0;
int j = i;
while(j < 5) {
printf("%d", i);
j = ++i;
}
...
int i = 0;
int j = i;
while(j < 5) {
printf("%d", i);
j = i++;
}
}</stdio.h>
True or False?
False
These two loops (left and right) produce the same thing
#include<stdio.h>
int main()
{
int i = 0;
while(i < 5) {
printf("%d", i);
\++i;
}
...
int i = 0;
while(i < 5) {
printf("%d", i);
i++;
}
}</stdio.h>
True of False?
True
What is faster n++ or n = n+1?
n++
++n is even faster than n++ in theory, since ++n doesn’t return the old value of n but n++ does.
In C, 1D array of int can be defined as follows and both are correct
int array1D[4] = {1,2,3,4};
int array1D[] = {1,2,3,4};
True
What is the index of the last element for the following array:
int pricesArr[100];
99
Given: int maxScores[4] = {20, 20, 100, 50};. What is maxScores[3]?
50
What is the resulting array contents, assuming it starts with an array of size 4 having contents -55, -1, 0, 9?
for (i = 0; i < 4; ++i) {
itemsList[i] = i;
}
-54, 0, 1, 10
0, 1, 2, 3
1, 2, 3, 4
0, 1, 2, 3, 4
0,1,2,3
What is the resulting array contents, assuming it starts with an array of size 4 having contents -55, -1, 0, 9?
for (i = 0; i < 3; ++i) {
itemsList[i+1] = itemsList[i];
}
-55, -55, -55, -55
0, -55, -1, 0
Out-of-range access
-55, -55, -55, -55
What is the output of this program?
int main()
{
int i;
int arr[5] = {1};
for (i = 0; i < 5; i++)
printf(“%d “, arr[i]);
return 0;
}
a)1 1 1 1 1
b)0 0 0 0 0
c)1 and four garbage (undefined or random) values
d)1 0 0 0 0
D
In C, 2D array of int can be defined as follows correctly
int array2D[2][4] = {1,2,3,4,5,6,7,8}; /* (i) /
int array2D[][4] = {1,2,3,4,5,6,7,8}; / (ii) /
int array2D[2][] = {1,2,3,4,5,6,7,8}; / (iii) /
int array2D[][] = {1,2,3,4,5,6,7,8}; / (iv) */
a) (i) is correct
b) (i) and (ii) only are correct
c) (i), (ii), and (iii) only are correct
d) (i), (ii), (iii), and (iv) (all are correct)
B
C language doesn’t provide any true support for 2D array or multidimensional arrays. A 2D array is simulated via 1D array of arrays. So a 2D array of int is actually a 1D array of array of int.