Do you know that? 62.9% freelancers are single, 37.1% - married next

Contact Email: teammmrem@yahoo.com

<< All Upwork (oDesk) and Elance Tests << Elance test answers << IT & Programming category

Test answers for System Programming 2020

(84) Last updated: February 28
Elance • IT & Programming
Questions and answers are regularly updated. Answered and not answered tests questions.

This helps getting job: Hundreds of (cover letter examples , interview questions , profile samples ) • Earn on Upwork (oDesk)
Job assistance: jobs popularityfreelance rates

Popular test answers: HTML, .Net, CSS, English, SEO, Photoshop, iOS, Java, Android, Ruby, Python, JavaScript

See all 6 tests answers updated

Find Upwork (oDesk) and Elance test answers on this website:



Collapse | Expand

84 Answered Test Questions:

1. Where would you expect to encounter the following code?         for (i=1; i<argc; i++) {                 if (argv[i][0] == '-')  {

Answers:

• In the scanning for an internals function

• Anywhere at all

• In the iteration of the fscanf() function

• In the beginning of the main() function

2. Which of the following could the fork() command return to the child process?

Answers:

• 0

• 2054

• 19456

• -1

3. Which of the following is true of hard links?

Answers:

• Hard links are directory entries that point to the same inode as another file

• Hard links can cross filesystems

• Files are deleted from disk when a hard link is removed

4. An orphan process occurs as a result of which of the following conditions?

Answers:

• Parent and child process terminate simultaneously

• Child process terminates before its parent process

• Parent process terminates before its child process

5. Using a terminal you want to log in to an account on a remote computer and securely build. Which would you use?

Answers:

• rlogin

• EncryptoTelnet

• SSH

• RSH

6. You want to listen on a port for some user-defined data stream. Would you use port 80?

Answers:

• Yes, it is as good as any other port number.

• No, it is a 'well-defined' or reserved port.

• No, it is best to use three or four digit port numbers.

• Yes, it is best ot use low numbers for port numbers.

7. When communicating across sockets, which of the following functions must be used when the socket is in a connected state?

Answers:

• sendmsg()

• sendto()

• send()

8. You want the same codebase to conditionally compile on and for different target platforms.  Which of the following would you use?

Answers:

• Use host-specific linkers

• Bit flags and bitwise OR'ing

• #itdef, #ifndef, and #endif

• if, else if, and else blocks

9. Using strncpy() to copy strings can help prevent which of the following attacks?

Answers:

• Man-in-the-middle

• Password cracking

• Buffer overflow

• Denial of service

10. Some programme that streams data to a hard-disk file in a loop crashed before it closed the FILE pointer. When the output file is inspected side-by-side with the logs, it is clear that the fprintf() function previous to the crash was unsuccessful. Such a situation can be averted using which one of the following?

Answers:

• sscanf()

• fbuffer()

• fflush()

• fscanf()

11. Given the following line: my_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, 0644);  Which statement is true?

Answers:

• Runtime error opening the file as the various flags and modes are in conflict

• Opens a file descriptor, bitwise OR'ing output flags and in mode 644

• Syntax error; the function takes only one more argument after 'filename'

• Syntax error; the second argument should be a single integer type

12. You see the line:  listen (s, 3); You are looking at code for:

Answers:

• A server's clients

• A server's socket

• A client's socket

• A client's server

13. Race conditions are caused by which of the following conditions in a multithreaded system?

Answers:

• Proper program function requires all threads to run quickly

• Proper program function requires that all threads run at the same speed

• Proper program function is dependent on the execution sequence and timing of each thread

14. The language of choice for Systems Programming is:

Answers:

• ALGOL

• LISP

• None of these

• PHP

15. The purpose of the poll() and select() system calls is to perform which of the following functions?

Answers:

• Sample system process information for use by the top command

• Frequently check email and other network services

• Watch a set of file descriptors to see which are ready

16. Which one of the following is NOT applicable in real-time Systems Programming?

Answers:

• Timing Diagram

• Event Trace

• Sequence Diagram

• E-R Schema

17. If a function is a 'blocking function' then:

Answers:

• The function is written using block structuring

• This function's purpose is to block unstructured calls

• This function has the highest possible priority

• The function must terminate before control returns to caller

18. Threads and processes are related in which one of the following ways?

Answers:

• Threads and processes exist separately

• Each process exists within a thread

• Each thread exists within a process

19. When a new process is created using fork(), which of the following describes the state of open file descriptors?

Answers:

• The child inherits the parent???s

• The child always has an empty set of closed descriptors

• The child overwrites the parent???s

• The child has distinct copies of the parent???s

20. If you see:  int ff; write(ff, data, sizeof(data)); you know that ff is:

Answers:

• a file descriptor

• a file function

• a file pointer

• a file struct

21. What is thread safety?

Answers:

• Threads don???t start until all of the resources they require are available

• Multiple threads can be executed without corrupting shared data

• Threads can only access the data in its process

22. Which of the following is correct for the standard file descriptors that are automatically opened in UNIX?

Answers:

• STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2

• STDERR_FILENO = 0, STDOUT_FILENO = 1, STDIN_FILENO = 2

• STDOUT_FILENO = 0, STDERR_FILENO = 1, STDERR_FILENO = 2

• STDIN_FILENO = 0, STDERR_FILENO = 1, STDOUT_FILENO = 2

23. Is it good programming that the following function call is recursive? void func(unsigned long a)  {          unsigned long x;          struct t_struct[] *p;          :          p = (struct t_struct *)alloca(a*sizeof(t_struct));          :          While (x = f2())                   func(x);          :          return; }

Answers:

• No, because iteration is always preferable to recursion

• No, because both stack depth and stack-frame size are unpredictable

• Yes, because recursion is always preferable to iteration

• No, because there is more than one 'long integer' type

24. Which of the following methods is used by system programs to access a character device (such as keyboards, audio cards, etc) on a UNIX system?

Answers:

• Standard file access functions

• It depends on the device

• Pipes

25. Which of the following IPC mechanisms has an inode?

Answers:

• unnamed pipe

• named pipe

• semaphore

• shared memory

26. Which of the following fields in the stat struct contain last time the file was modified?

Answers:

• st_ctime

• st_atime

• st_mtime

27. Correct the following code: 10                int my_sock; : 20                my_sock = socket(anaddr.sin_family, SOCK_STREAM, 0); 21                if (my_sock >= 0) {                         /* error processing */                 :                 }

Answers:

• line 20: my_sock = socket(SOCK_STREAM, anaddr.sin_family, 0);

• line 21: if (my_sock < 0) {

• line 20: my_sock = (int *)socket(anaddr.sin_family, SOCK_STREAM, 0);

• line 10: SOCKET * my_sock;

28. Any code that calls a function whose interface includes the line raises(aLibrary:BookIsMissing); should do which one?

Answers:

• #include errno.h header file

• Pass both parameters by reference

• Implement an exception handler

• Properly pass parameter for Book

29. Which of the following provides the most random seed source for a pseudo random number generator?

Answers:

• /dev/random

• C rand() function

30. Which of the following best describes the purpose of the unlink() call?

Answers:

• Removes the file from its directory

• Moves the file in from one directory to another

• Sets the file???s inode count to one (1)

31. The ioctl() function is used to interact with which of the following?

Answers:

• Virtual TTY lines

• Special character devices

• Disk Drives

32. What does the following line do?         memset((char *)&ctl_addr, 0, sizeof(ctl_addr));

Answers:

• Initializes the region of memory pointed to by &ctl_addr

• Given that 0 is passed, it unsets the memory of ctl_addr

• Initializes a subset of memory pointed to by &ctl_addr

• Allocates and initializes memory for variable ctl_addr

33. Given:  int s, l; struct sockaddr_un sock_struct;  Choose the option that corrects the following line:  bind(s, sock_struct, l);

Answers:

• bind(sock_struct, s, l);

• bind(s, l, sock_struct);

• bind(s, sizeof(sock_struct), l);

• bind(s, &sock_struct, l);

34. What does the line #define S_IRWXG 0000070 relate to?

Answers:

• Alpha-numeric interchange

• Defining bitwise flags

• User-defined typing

• Flags for file access

35. In Multi-Threaded programming you want an active thread to push itself back in the background in favour of some other thread. You will use which function:

Answers:

• pthread_setschedparam()

• sched_yield()

• pthread_cancel()

• pthread_detach()

36. The sticky bit is used to enable which of the following features?

Answers:

• Prevent users from renaming or deleting files created by other users

• Keep a process from swapping out of memory

• Aggressive caching of a process

37. What does the following function return?          Class                         retVal = [self class];         if ([retVal class] != [NSObject class])  {                   while ([retVal superclass] != [NSObject class])                          retVal = [retVal superclass];         }         return retVal;

Answers:

• The root object

• The present object's ultimate superclass or base class below the root object

• The present object's superclass or base class

• The present object's class

38. When there are more fork() calls than wait() calls, which of the following is created?

Answers:

• orphan

• zombie

• thread

• daemon

39. Thread joining synchronizes threads by doing which of the following?

Answers:

• The system manages the shared resources for the joined threads

• The joined threads are added to a queue and executed serially

• The thread that calls join blocks until all of the joinable threads complete

40. You want a char * that will contain the timestamp as YYYYMMDD-hh:mm:ss . You would use:

Answers:

• strftime()

• get_datetime()

• localtime()

• sprintf()

41. Using two resident processes on a PC and a Unix box, you are streaming unbuffered the contents of a text-file byte by byte from the PC to the Unix box where it is written byte by byte to the local hard disk. Eyeing the written file it is obvious that it is not quite right. You have likely run into which problem?

Answers:

• Text file versus binary file

• Not using buffered streaming

• Big endian versus littlen endian

• Ignoring the parity bit

42. The following code is written to be accessed by multiple detached threads. : const char * c; char * d; : /* no lock and no mutex is used in any way here */ my_print_func (c, &d); : Which one of the following will happen when this code is re-entered by multiple threads?

Answers:

• The code will always cause a crash

• It isn't possible to tell without looking at my_print_func()

• One thread will run while others will crash or abort

• The code will sometimes run and sometimes cause a crash

43. In an IDL which one of the following is NOT a valid declaration?

Answers:

• oneread

• oneway

• enum

• readonly

44. In UNIX, a program requires higher privileges in order to do which of the following?

Answers:

• Open a file in the owner???s directory

• exec() a new process

• Listen on a port below 1024

• Create a file in the /tmp directory

45. What type of attack can be mitigated by using ulimit, setrlimit(), and quotactrl()?

Answers:

• Man-in-the-middle

• Password cracking

• Buffer Overflow

• Denial of service

46. Which of the following is the result of a process calling UNIX exec()?

Answers:

• The process becomes executable

• The process blocks waiting for another process to run

• The process is completely overwritten

• A new process is created

47. What is a UNIX directory?

Answers:

• A file that contains other files

• A special type of inode

• A list of files

48. What is the purpose of a semaphore?

Answers:

• To protect a critical section of code

• To protect shared variables

• To protect a shared memory region

49. Which of the following can be called to remove zombie processes?

Answers:

• flush()

• close()

• wait4()

• free()

50. What will happen when the compiler 'sees' the following code? #define FTP_TYPE  "" #ifdef -FTP #define FTP_TYPE  "FTP" #elif #ifdef -PASV #ifndef FTP_TYPE #define FTP_TYPE  "PASV" #endif #endif

Answers:

• Compile will proceed with a warning of #define'ing a symbol as a string

• Compile will fail with an error of #define'ing a symbol as a string

• It is neither 'code' nor will the compiler 'see' it

• It's not a question of 'when' but if: compiler will 'see' it only if -FTP or -PASV is set

51. You are coding a multi-threaded server in which n detached threads will listen on n ports with a permanent one-to-one association between threads and ports during the lifetime of the process. You want to uniquely identify each thread-port pair. To do so you:

Answers:

• must use both thread-id and port number

• can use thread-id but not port number

• may use either thread-id or port number

• can use port number but not thread-id

52. Which of the following advocates the use of memmove() over memcopy() for performing fast data copying from one buffer to another correctly?

Answers:

• The buffers are large

• The buffers are small

• The buffers will not overlap

• The buffers may overlap

53. In gdb before using 'jump' you would typically do which one of the following:

Answers:

• gdb has no 'jump' instruction

• Either 'step' or 'next'

• Do a backtrace

• Set a breakpoint

54. A 'crashed' software needs to be debugged using its core dump. You would start by doing:

Answers:

• step

• attach

• backface

• inspect

55. Given:  int s, l; struct sockaddr_un sock_struct;  The following function call: connect(s, &sock_strict, l); fails. Which one is NOT a reason for it to fail?

Answers:

• The value of s is negative

• sock_struct passed by reference

• Sercer not listening on sock_struct

• No server bound on sock_struct

56. Which of the following techniques can help keep system programs secure?

Answers:

• Limit system calls to administrators

• Encrypt every process??? executable

• Check all system calls for error conditions

• Setuid important processes to the root user

57. Wha does the following line do?   unsigned transOK : 1;

Answers:

• Identifies a bit in a byte to use as a flag

• It sets the transOK flag to 1

• Conducts a bitwise operation on transOK and 1

• Declares an unsigned integer and sets it to 1

58. In a Publish-And-Subscribe implementation, a subscriber must:

Answers:

• Know the event name or event identifier for one or more events

• (all of these)

• Be connected to one or more event publishers

• Use two-way messaging

59. You want to copy binary contents of memory from one location to another. Which one of these h-files will you #include?

Answers:

• stdio.h

• locate.h

• string.h

• mem.h

60. A thread has its own copy of which of th following?

Answers:

• Variables

• Files

• Stack

• Address space

61. Calling mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, input_fd, 4096), where input_fd is the file descriptor of a 16KB file will cause which of the following to occur?

Answers:

• The third 4KB of the file will be loaded into a 4KB memory location

• The fourth 4KB of the file will be loaded into a 4KB memory location

• The second 4KB of the file will be loaded into a 4KB memory location

• The first 4KB of the file will be loaded into a 4KB memory location

62. The result of calling kill(6003, 0) is which of the following?

Answers:

• The signal 6003 is sent to process 0

• The signal 0 is sent to process 6003

• The existence of process 6003 is checked

• Process 6003 terminates

63. Which of the following functions sends a signal to the executing process?

Answers:

• signal()

• call()

• send()

• raise()

64. Which is true, given the following code:                         tok = strtok_r(data, " ???, &last);                         while (tok)  {                                 strcat(strcpy(full_name, the_path), tok);                                 make_secondary(eAma_full_name, TRUE);                                 tok = strtok_r(NULL, " ???, &last);                         }

Answers:

• The syntax is wrong; it should be strtok(char *, const char *)

• Passing NULL as the first param to strtok_r() is an error

• Should not pass last by reference inside the while() loop

• Re-entrantly tokenizes on delimiter " ??? to stringify something

65. How can two processes communicate despite having firewalls between them?

Answers:

• SOCKS

• HTTP

• HTTPS

• (none of these)

66. Changing the mode of a file to be -rwxr-xr-x via the chmod system call can be achieved by setting the mode to which of the following values?

Answers:

• S_ISVTX | S_ISUID | S_IRGRP | S_IWGRP | S_IRXOTH

• S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH

• S_IRUSR | S_IRWXG | | S_IROTH | S_IXOTH

• S_IRWXU | S_IWGRP | S_IXOTH | S_IRWXO

67. An Internet socket connection essentially is:

Answers:

• A specific, system-defined socket structure

• The ANSI-defined SOCK_ADDR * structure

• Two host addresses and two port numbers

• A combination of file pointers and streams

68. In a Unix toolchain, which one of these pairs does not fit with the others?

Answers:

• Header file and preprocessor

• Object file and linker

• Executable and compiler

• Quads and assembler

69. CORBA's DII allows a client to do which one of the following?

Answers:

• Connect with proxy objects across platforms

• Generate client-side stubs for interfaces

• Discover new objects and interfaces at runtime

• Dynamically link with cross-platform libs

70. Which one of the folloing is NOT necessary for a basic CORBA system?

Answers:

• CORBAfacilities

• Stub and skeleton

• IDL files

• Naming Services

71. Which one is not a difference between exit() and _exit()?

Answers:

• One flushes and closes I/O streams; the other doesn't

• One is for the main process; the other for forked processes

• One does some work on its own, then calls the other

• One is a true system call; the other is a library routine

72. It is not possible to set the sticky bit of a file when creating it. Therefore it is necessary to create the directory and then set the sticky bit by executing: mkdir(???/tmp/dir???, 0744); chmod(???/tmp/dir???, 07744). Why?

Answers:

• The mkdir() command is privileged, and doesn???t allow any modification to permissions

• The behavior of mkdir() is undefined if anything other than permission bits is set

• UNIX requires that directories be created before any non-permission bits are set

73. In order to create a counting mutex, which mode does it need to use?

Answers:

• PTHREAD_MUTEX_DEFAULT

• PTHREAD_MUTEX_NORMAL

• PTHREAD_MUTEX_RECURSIVE

• PTHREAD_MUTEX_ERRORCHECK

74. Which of the following is an advantage of using pipes over shared memory for interprocess communication?

Answers:

• Faster access time

• Pipes connect processes on multiple machines

• Pipes can be shared by more processes

• No additional work required on multiple CPU systems without cache coherence

75. Thrashing caused by loading a large file can be reduced by mapping the file to memory due to which of the following features?

Answers:

• Mapped memory is cached

• Mapped memory uses prefetching

• Mapped memory uses lazy loading

76. In order to prevent signal handler race conditions, a developer must do which of the following?

Answers:

• Call sigsetmask() to set the signal mask to be blocked

• Call sigaction() to block the signal and set the signal mask at the same time

• Create a mutex within the handler to protect shared resources

77. What does this code do: BOOL sharedLockSuccess = NO; NSLock  *aMutex; :         sharedLockSuccess = [aMutex lockWhenCondition:1 beforeDate:[NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval)3600]];   :

Answers:

• A mutex is tried to be locked within a specific time

• A mutex is being set to be locked at a specific time

• A mutex is tried to be locked with a specific condition

• A mutex is being set to be locked upon a specific condition

78. Which of the following could the fork() command return to the parent process?

Answers:

• -1

• 0

• 4066

• 206896

79. Yousee the following function call in some code:  pthread_setspecific(key, value);  What will this allow the coder to do?

Answers:

• Access thread-specific data outside the thread

• Enable a thread to set and use data

• Insert key-value pairs into a thread's dictionary

• Use a key to identify a thread

80. Choose the answer that corrects the following code. FILE         * file1; :   if ((file1 = open("/valid_dir/existing_file", O_RDONLY, 0666)) == ERROR) {  /* /valid_dir/existing_file is guaranteed to exist  */ :

Answers:

• Replace the declaration with: int file1;

• Use either one of 'O_RDONLY' and '0666'

• Bitwise OR O_RDONLY with another flag

• Do not open a file within a condition

81. What does this code do:          [aLock lockWhenCondition:(int)self beforeDate:[NSDate  dateWithTimeIntervalSinceNow:maxTimeInterval]];

Answers:

• Control blocks for some time on a lock on a condition that is unique to an instance

• A lock is set using a compound condition comprising of self and a time interval

• A lock is locked if and when self is instantiated before a specific date-time

• It will have no effect at all

82. Recently your office's UNIX tool-chain was updated. Now, code that previously used to build and run still builds without any warnings or errors but displays load-time errors due to symbols not found in shlibs. You have ensured that all necessary shared libraries are present in the path 'pointed to' by the appropriate environment variable. Which is true?

Answers:

• Debugging info flags missing in Makefile

• Shared libraries should have been updated

• Compiler-Dynamic Linker incompatibility

• Outdated symbols in symbol table or link table

83. Sharing memory between processes using mmap vs. shm_open has which of the following advantages?

Answers:

• The memory buffer automatically expands to meet the needs of the processes

• The memory buffer is persistent beyond the life of the processes

• The memory buffer more quickly accessed

• The memory buffer is destroyed when the processes end

84. A pipe has been created, and fork() and exec() calls have been completed. What steps must be taken next in order to establish communication from the parent to the child?

Answers:

• The child must create a new pipe

• The parent must close pipe_fd[0], and the child must close pipe_fd[1]

• The parent must close pipe_fd[1], and the child must close pipe_fd[0]

• The parent must create a new pipe