201 Midterm
Suppose you wrote server code that will send messages out to all clients. The clients are single-line monitors that will display your received message without processing it. The problem is that, when the clients are receiving messages, they receive a newline with it and it wipes the original message. In your server code, you've written "pw.println(str); pw.flush();" where pw is an instance of a PrinterWriter object that writes to an output stream. What is a correct way to fix this (so that a newline is not sent)? 1) Rewrite the first quoted server-code line as "pw.println(str.replace("\n", ""));" 2) After writing "pw.println(str)", fill the buffer with white-space characters so that flush() can not insert a newline character 3) Rewrite the first quoted server-code line as "pw.print(str);" 4) The string must be reprocessed by the client to remove the newline character
3
Docker ... A) Allows developers to easily deploy their applications in a sandbox B) Allows users to package an application with all its dependencies into customized units C) Maximizes software packaging D) All of the above
A
How does a thread obtain the lock for an object? A) When a thread enters a synchronized block of code, it obtains the lock for that object B) ExecutorService delivers locks to threads in its Thread Pool fairly using methods (FIFO, Round Robin, etc) that are optimized and prevent starvation. C) Threads executing a synchronized block of code will pass the lock to the next thread. Effectively, the current thread will go to the Wait State. D) Java is thread-safe and the JVM will handle race conditions by giving the lock to the thread in the Running State
A
WebSocket is best suited for... A) Dynamically sending and receiving messages B) Putting on a sock C) Loading web content without refreshing D) Streaming multimedia content
A
What does HTML stand for? A) Hyper Text Markup Language B) Hyper Text Modeling Language C) Hypertext Transfer Markup Language D) None of the above
A
What is not an advantage of multithreading? A) Testing/debugging is usually relatively straightforward, in comparison to other approaches B) The independent nature of threads means other threads are not affected if an exception occurs in one C) It doesn't block the user from performing other tasks D) One can save time by performing many tasks togethe
A
What is the "novel" idea that Tim Berners-Lee invented? A) Hyperlinking B) HTML and CSS C) Hypercard D) Deep Linking
A
What is the motto of Java? A) Write once, run anywhere. B) Platform-independent. C) Run once, write anywhere. D) Better than C++
A
Which Java IDE will be used in the class and by the graders? A) Eclipse B) BlueJ C) IntelliJ D) NetBeans
A
Which of the following is the correct way of serializing an object? A) ObjectOutputStream out = new ObjectOutputStream(newFileOutputStream("output.ser")); out.writeObject(new int[]{1,2,3}); B) ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("output.ser")); out.writeBytes(new int[]{1,2,3}); C) FileOutputStream out = new FileOutputStream("output.ser"); out.writeObject(new int[]{1,2,3}); D) FileOutputStream out = new FileOutputStream("output.ser"); out.write(new int[]{1,2,3});
A
Which of the following statements regarding networking is/are true? A) Ports allow us to uniquely identify networked programs running on a single computer. B) Private IP Addresses can communicate outside local networks. C) Multiple computers on the same network can share the same IP address. D) All of the Above
A
Which one presents the correct ways for creating CSS selectors? A) .classname#idnametagname B) .classnameidname#tagname C) classname#idname.tagname D) #classname.idnametagname
A
Which statement below is false? A) Updates to a page made via AJAX will not be displayed until the client's window is refreshed B) AJAX applications can transport data as JSON text C) AJAX stands for Asynchronous JavaScript And XML D) AJAX uses a browser built-in XMLHttpRequest object
A
With Virtual Machines, it is difficult to predict the size of the VM instance. A) True B) False
A
Which of the followings are needed for a socket to connect to a server application? A. IP address of the server; B. the port on which the server application is listening; C. IP address of the client; D. client's port number.
A and B
A monitor is an object with _____ exclusion and synchronization capabilities. A) multi-threaded B) mutual C) conflicting D) parallel
B
How are Java objects allocated? A) All Java objects are statically-allocated. B) All Java objects are dynamically-allocated. C) Java doesn't have objects but just primitive variable types. D) Java gives the programmer the ability to allocate objects either dynamically or statically.
B
In AWS Lambda ... A) Functions can be triggered only from HTTP B) You never pay for idle time C) Auto-Scaling is sometimes Available D) All of the above
B
In what class is monitor functionality implemented? A) Unit class B) Object class C) Sync Class D) Lock class
B
Select the correct statement from the following options. A) Parallelizing code always speeds it up. B) If you fork more threads than your CPU's, the threads will execute concurrently. C) Forking a task causes no overhead. D) All of the above.
B
The lock for a synchronized, non-static method is on the _____, and for a synchronized, static method it is on the ___. A) class, class B) object, class C) object, object D) class, object
B
What is a socket? A) Socket is the IP address of the server. B) Socket is the combination of the IP address and port number needed by the client. C) Socket is the IP address of the client. D) Socket is the port number of the client and server connection.
B
What is the correct way to make sure a form uses a servlet you created? A) Set the name parameter in the url to the name of the servlet. B) Set the action attribute of the form to the name of the servlet. C) Set the name attribute of the form tag to the name of the servlet. D) Set the method attribute to POST in the form tag.
B
What is the producer/consumer problem, and why is it important? A) Producers withdraw items, consumers insert items, and this is an example of parallel programming. B) Producers insert items, consumers withdraw items, and this is an example of concurrent programming. C) Producers withdraw items, consumers insert items, and this is an example of concurrent programming. D) Producers insert items, consumers withdraw items, and this is an example of parallel programming.
B
Where are files stored in a computer system? A) Volatile memory B) Non-volatile memory C) Cache D) Main memory
B
Which of the following is true about Java inheritance? A) Java does not support inheritance. B) Java supports single inheritance. C) Java supports multiple inheritance. D) Java supports single and multiple inheritance.
B
Which of the following is true? A) If a method only exists in the child and you have an instance of a parent, you can still call the method from the child. B) An object with the compile-time type of a parent can take on the form of a child at runtime. C) Both A and B D) Neither A nor B
B
Is 172.21.101.211 a public IP Address or a private IP Address? A) Public B) Private C) Both D) Neither
B --> class B
A thread with a priority of 10 will run before a thread with a priority of 1. A) This is always true B) This is never true C) This is sometimes true D) None of the above
C
If thread is a Thread object, calling thread.sleep(10) will cause the thread to sleep for ________ A) approximately 10 milliseconds (could be more, could be less) B) exactly 10 milliseconds C) at least 10 milliseconds D) at most 10 milliseconds
C
What's the purpose of NAT (network address translation)? A) It solves the problem that IPv6 has run out of available addresses. B) It connects the port number to the DNS server. C) It replaces the private IP address with the public IP address on outgoing request. D) It determines the IPv4 address class.
C
Which of the following is NOT true about semaphores? A) A thread can release permits on a semaphore even without having them. B) Semaphores can restrict the number of threads that access a shared resource. C) Only one permit is available on a semaphore. D) The number of permits available on a semaphore is specified at creation.
C
Which of the following statements regarding Thread Priorities in the JVM is true? A) High priority threads will always execute before threads with lower priority. B) Threads are scheduled in order from highest priority to lowest priority. C) When the JVM decides on the next thread to execute from the ready state, it follows a probabilistic algorithm. D) None of the above
C
Why would you use JavaScript on the front end for form validation? A) You can't. Form validation can only happen on the backend. B) Because this is the only place you can perform form validation. C) Because even though you also have to do it on the backend, JavaScript allows the form validation to happen without reloading the page or even submitting to the server. D) Because you have a choice between doing it on the front end or the backend, so sometimes you choose the front end.
C
Why does AJAX exist? A) To reload part of a page without refreshing the entire page. B) To asynchronously send data to the server to validate information. C) Both A and B D) Neither A nor B
C (A and B)
A monitor... A) cannot be created. B) must extend the monitor class. C) must implement the monitor interface. D) can be any object.
D
A parent class is also known as what? A) Child class B) Upper class C) Senior class D) Base class
D
By convention in Java, all classes start with... A) an underscore B) a number C) a lowercase letter D) a capital letter
D
Containers ... A) Are lightweight B) When running on same host, share same Linux kernel C) Are portable D) All of the above
D
FaaS ... A) is Function as a Service B) is Custom code C) Runs on ephemeral containers D) All of the above
D
Given a table of state names, how would you select only the abbreviation and full-name of California? A) SELECT full_name, abbreviation FROM us_state_info IF state IS 'California' B) SELECT * FROM us_state_info WHERE full_name='California' AND abbreviation='CA' C) SELECT full_name, abbreviation FROM us_state_info D) SELECT full_name, abbreviation FROM us_state_info WHERE full_name='California'
D
Given these two tables: CREATE TABLE Students{ID int(11) primary key not null auto_increment;firstname varchar(50) not null,lastname varchar(50) not null,country varchar(50) not null,}; Which one of these queries are correct to change student with ID 10 country to 'United States' ? A) SET Students s, s.country = 'United States'' WHERE s.ID = 10; B) You can't update values in SQL you have to deleted the entry and add a new one. C) CHANGE Students s, s.country ='United States'' WHERE s.ID = 10; D) UPDATE Students s SET s.country ='United States'' WHERE s.ID = 10;
D
How could you normalize a table that has a persons name, social security number, date of birth, and list of properties they own? A) Make names its own table with the name as the primary key, and the date of birth as a foreign key. B) This table is already as normalized as it can be. C) Make the property names an array instead of a column D) Make the social security number its own table with the social security number as the primary key, and the date of birth and name as columns. Then also make a properties table with a property id, property name, and social security number as the foreign key.
D
What are solutions to the cross-domain issue for resources such as JavaScript of JSON? A) Use a server "proxy" B) Use CORS, if available C) Access exclusively resources in the same domain D) All of the above
D
What code is embedded in JSON.parse() ? A) evaluate() B) XMLHttpRequest.status C) JSON.stringify() D) eval()
D
What does a client application need to connect to a server application? A) IP Address B) Socket C) Port D) All of the above
D
What function can be used to get a single HTML element from the page? A) getElementsByName() B) getElement() C) getElementByClassName() D) getElementById()
D
What is the purpose of the IFRAME element? A) reserve a rectangular region B) hyperlink to a site C) embed a plug-in D) embed a site
D
What type of inheritance does Java support? A) Java does not support inheritance B) Multi-Dimensional C) Multiple D) Single
D
What's the purpose of NAT (network address translation) A) It connects the port number to the dns server B) It determines the IP address class C) It solves the problem that ipv6 has run out of available addresses D) It replaces the private IP address with the public IP address on outgoing request
D
Where do JavaScript functions belong? A) Anywhere in the html file B) In an external html file C) in the <body> tag D) in the <head> tag
D
Which does a client application need to connect to a server application? A) IP Address B) Socket C) Port D) All of the above
D
Which of the following are true about Java servlets? A) Servlets can process data through doGet(), doPost(), and service(). B) Servlets are compiled and executed on the server, but then generate client-side code to send back to the browser. C) Servlets are Java classes that can serve dynamic web content. D) All of the above.
D
Which of the following are true when you are designing test cases? A) Choose inputs that force the system to generate all error messages. B) Repeat the same input or series of inputs numerous times. C) Force invalid outputs to be generated. D) All of the above.
D
Which of the following is false, on the topic of differences between processes and threads? A) Processes are independent, threads are a subset of a process B) Processes have different address space in memory, whereas threads contain a shared address space C) Communication between processes is slower and more costly in comparison to communication between threads D) Context switching is faster between processes in comparison to threads
D
Which of the following is not a front-end web language? A) CSS B) HTML C) JavaScript D) Java
D
Which of the following statements regarding semaphores is correct? A) A thread can release permits on a semaphore even without having them. B) A thread must acquire one of the permits of the semaphore before executing code managed by a semaphore. C) The number of permits available on a semaphore is specified at creation. D) All of the above.
D
Which of the following statements regarding software engineering is correct? A) An increase in testing costs will bring down the cost of software maintenance. B) Pair programming with junior programmers can decrease the overall cost of a software product. C) Software project cost estimation is not known until the technical specifications are written. D) All of the above
D
Why is a performance increase not guaranteed for parallel computing? A) Parallel computing adds functionality and does not increase performance. B) Network delays cause performance bottlenecking. C) Modern-day CPUs have sufficient single-core performance. D) Forking and joining has their own overhead.
D
What's the purpose of NAT (network address translation)? A) It solves the problem that IPv6 has run out of available addresses. B) It connects the port number to the DNS server. C) It replaces the private IP address with the public IP address on outgoing request. D) It determines the IPv4 address class.
It replaces the private IP address with the public IP address on outgoing request.
Which of the following ranges of port numbers refers to ports that are registered and can be used by any application? a) Ports from 1024-49151 b) Ports from 0-1023 c) Ports from 49152-65535 d) None of these ranges
a
Which of the following is true about subnets? a) In order to achieve subnetting, we take away bits form the host in both IPv4 and IPv6 b) A subnet mask can be written as "/# of zeros" c) A subnet mask will consist of of all 1's followed by all 0's. d) In IPv6 the subnet bits are 65-128
c
What is the effect of a WHERE clause?
conditional cut
Which of the following is NOT a reserved port for well known applications? a) 143 b) 443 c) 20 d) 1024
d
What is the effect of changing from SELECT * to SELECT g.Grade?
vertical cut