考试代写-CSE 15L
时间:2021-12-05
UCSD CSE 15L Final Practice Problems Fall 2019
(True/False questions)
1. A Unix pipe is a way to send the standard output of one command to the standard input of
another.
2. In XML, comments begin with //.
3. Assuming the logging level is set at INFO, messages with level FINE will be logged.
4. Git uses a Distributed Model.
5. The init process has a PID of 1.
6. The proper syntax for setting a variable named bar to "abc" in Bash is bar = "abc"
7. Pipes (|) and redirects (>) can always be used interchangeably.
8. In Unix, by default / is the HOME directory.
9. In Bash scripts, while loops are terminated by the elihw keyword.
10. Using java.util.logging, mylogger.severe("Unhandled ex") and
mylogger.log(Level.SEVERE, "Unhandled ex") have the same functionality.
11. A control variable defined as protected static boolean LOGGING_EN = False
will result in all guarded logging statements (i.e. if (LOGGING_EN)
{mylogger.log(…);} being compiled out of the resulting program.
12. All Daemon processes have a PPID of 1.
13. Ending a command with % will cause the resulting process to run in the background.
14. Running a Bash script using source myscript.sh will run myscript.sh in a new Bash
shell.
15. git can only be used with a GitHub repository.
16. The jobs command will list all background processes spawned from the current terminal.
17. In java.util.logging, the Handler class exports log messages to a given target, such as
a file or the console.
18. Virtual Machine images are larger than their applications because they contain a guest operating
system in each image.
19. A hypervisor sits between virtual machines and the hardware of a computer.
1
UCSD CSE 15L Final Practice Problems Fall 2019
(Multiple Choice and Short Answer)
1. In the Level class (java.util.logging.Level), when specifying the importance level
of log messages, which constant has the second highest importance out of the following?:
(a) Level.CONFIG
(b) Level.WARNING
(c) Level.FINER
(d) Level.INFO
2. Software runtime costs can be described using functions of ___________ , ___________ and
___________.
3. List the Unix commands for the following tasks:
i. Removes all text on the terminal and brings the cursor to the top left
ii. Searches any given input files, selecting lines that match one or more pattern
iii. Display the contents of the file file1.txt located under the home directory of the user
iv. Displays the current user’s programs executing in the background from the current
command shell
v. Prints the path to the user’s home directory to standard output
vi. Change the current directory to the Temp folder in the Volumes directory under the root
directory
4. Fill in the outputs of the echo statements in the following Bash script:
#!/usr/bin/bash
a=Hello
b=world
foo='$a, $b!'
bar="$a, $b!"
echo $foo # outputs _____________
echo $bar # outputs _____________
echo $foo+1 # outputs _____________
2
UCSD CSE 15L Final Practice Problems Fall 2019
5. What is the gdb command to set a breakpoint at a function named main() when already in
gdb debugging a program?
6. For the command ./doabarrelroll.sh 360 , list the output of the echos for the
following positional arguments:
echo $# _____________
echo $0 _____________
echo $1 _____________
7. Answer the following questions about the Unix system:
i. List 3 common Unix tools for archiving, zipping, and unzipping files.
ii. In a single command, output the manual of grep to a program that allows you to scroll
through the text.
iii. Write two Unix commands: one that defines a shell variable named TheTutor with an
initial value of "Nate" and one that displays the value of the variable.
8. Assuming the file Hyperdrive.sh originally has rw-r---wx as access permissions, the
resulting permissions of the file after running chmod a-w,u+x Hyperdrive.sh can
be represented in octal notation as:
chmod ______ Hyperdrive.sh
3
UCSD CSE 15L Final Practice Problems Fall 2019
9. Answer the follow questions about Unix processes:
i. Explain the similarities and differences in terms of standard input and output between
running a program in the foreground and background.

ii. You are writing a script and do not want the program to terminate when is
pressed. Instead, you want to display a reminder to the user that "YY copies the line". What
line can you write in your Bash script to accomplish this?
________ ____________________________ ____________
If your script has a PID of 404, what command from the terminal will allow you to test this?
________ ________ ________
10. Answer the following questions about git:
i. Explain what the following commands do in git:
git checkout ____________________________________________________
git reset ____________________________________________________
git rm ____________________________________________________
git branch ____________________________________________________
ii. List the git command to remove all files from the staging area.
iii. List the git command to transition a file called myfile.c from modified to unmodified
without committing it.
iv. For updating your local repository, what is the difference between git pull and git
fetch?
v. Explain the difference between git and GitHub.
4
UCSD CSE 15L Final Practice Problems Fall 2019
11. Answer the follow questions about diagnostic output:
i. Why would a programmer want different levels of logging during production and after a
commercial release?
ii. List and describe the interaction between the 4 main classes in java.util.logging.
iii. For the following code, how would you log a severe message with text of
"Unexpected error" and the stack trace?
...
try {
serviceNetwork(addr_target);
}
catch (Exception ex) {
logger_network.log(__________, __________, __________);
}
...
5
UCSD CSE 15L Final Practice Problems Fall 2019
(Analysis and Design Problems)
1. Please use the following build.xml file in Ant to answer the following questions.
















/dev/null"); // Calculates pi to 3000 digits
17 arr_times[1] = time(NULL);
18
19 // Calculate and output the difference in seconds
20 time_diff = arr_times[1] - arr_times[0];
21 printf("%ld s\n", time_diff);
22 }
23
24 free(arr_times);
25
26 return 0;
27 }
i. How would you compile the above code so that you can use it with a debugger or valgrind?
(Note: The code above is written in c.)
ii. Using the file compiled above, how would you execute valgrind to check for memory leaks?
iii. After running the code through valgrind, you get the following output:
...
==26662== Command: ./example1
==26662==
6 s
5 s
6 s
...
==26662== 32 bytes in 2 blocks are definitely lost in loss record 1 of 1
==26662== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-
linux.so)
==26662== by 0x10878C: main (example1.c:12)
...
What type of error is valgrind reporting? (Bonus points: why?)
8
UCSD CSE 15L Final Practice Problems Fall 2019
3. The command cat goldenBoy.sh outputs:
#!/bin/bash
counter=0
for num in {1..30}; do
if (($num % 5 == 0)); then
echo -n "$num "
counter=$((counter + 1))
fi
done
echo ""
echo "Counter is: $counter"
Assuming we have the correct permissions, when you run ./goldenBoy.sh, what is the
output on your terminal?
4. Fill in the blanks in the following shell script to create a script that asks the user for two
numbers, multiplies them together, and appends the output to a file named results.log.
#!/bin/bash
echo "Enter two numbers:"
<__i.__> num1 num2
product=`<__ii.__> <__iii.__> <__iv.__> <__v.__>`
<__vi.__> "$num1 x $num2 = $product" <__vii.__> results.log
i.
ii.
iii.
iv.
v.
vi.

vii.
9
UCSD CSE 15L Final Practice Problems Fall 2019
5. who and grep are two Unix commands with the following excerpts from their man pages:
NAME
who - show who is logged on
SYNOPSIS
who [OPTION]... [ FILE | ARG1 ARG2 ]
DESCRIPTION
Print information about users who are
currently logged in.
-b, --boot time of last system boot
-p, --process print active processes
spawned by init
Write a Unix command to redirect who is on the
system to a file called current_users.log,
overwriting the file if it already exists.
Write a command to filter out and display the lines
in current_users.log that contain cse15l
Write one command to print the count of the
number of users that contain cse15l without
using a text file. (Hint: use pipes and filters).
NAME
grep -- print lines matching a
pattern
SYNOPSIS
grep [OPTIONS] PATTERN [FILE...]
DESCRIPTION
grep searches the named input FILEs
(or standard input if no files are
named), for lines containing a match
to the given PATTERN. By default,
grep prints the matching lines.
-c Suppress normal output; instead
print a count of matching lines
for each input file.
-i Ignore case distinctions in both
the PATTERN and the input files.
-v Invert the sense of matching, to
select non-matching lines.
10


essay、essay代写