Technical Questions

Computer Science, Electrical and Computer Engineering, Information Science…these questions are for you!

Object-Oriented Programming

  • What is passing by reference? Passing by value?
    • By reference: you are sending the variable memory location so that the method that receives the var can edit the original memory location
    • By value: you are sending a copy of the variable value so that a new memory location will be created - good way to avoid overwriting original variable value
  • What is a shallow copy? Deep copy?
    • Shallow copy: you are copying a variable's memory location. Basically, passing by reference. Say you have a memory location A and the value of A inside that location is 10. A shallow copy will pass on ONLY the memory location, not the value.
    • Deep copy: you are copying the variable's values. Basically, passing by value. Using the previous example of memory location A, a deep copy will NOT copy the memory location; it will copy the value 10 and create a whole new memory location to store the value 10.
  • What does public, private, and protected mean?
    • Here's a handy visibility chart:
Modifier Class Package Subclass World
none Y Y N N
public Y Y Y Y
protected Y Y Y N
private Y N N N
  • Abstract classes vs. Interfaces?
    • Abstract classes: each class can extend ONE of these. Use this when you need to change the core architecture/design of the class itself. For example, you would have a Dog class extend an abstract Animal class and this Animal class would have the appropriate soundsLike() method, livesIn() method for the Dog class to define.
    • Interfaces: each class can implement MANY of these. Use this when an object needs several interface influences (i.e. Dog implements MansBestFriend, DomesticAnimal)
  • Why is Java often considered a more stable language than C++?
    • C++: dangerous memory allocation functinos (beware buffer overflow), worrying about passing by reference or value, and most importantly C++ is not platform-independent - this means that in order to pass a C++ app from one OS box to another (for ex. windows to linux) you need to send the source code and recompile it to get the application.
    • Java: garbage collection done automatically by the VM, no scary memory allocations, variables pass by value by default (so if method 1 sends a variable to method2, the variable at the memory location 1 is not edited by the second method since the second method will create an entirely new memory block with the variable value inside. (Also, I find Java more user-friendly via nicer and more obvious syntax)
  • What defines Object Oriented Programming? Why is OOP good?
    • encapsulation
    • modularity
    • inheritance
    • polymorphism
    • abstraction

For more, see Wikipedia: OOP

Core Java Questions

30 Core Java Questions

Databases

  • What does a typical database connection entail?
    • Use a connection driver like JDBC to connect to the db, login, using the credentials you provided, once authenticated, execute your queries and if returning records save the records into a ResultSet, step through the ResultSet, close the connection
  • How do you make sure that whenever you connect to a database you always close the connection?
    • try, catch, finally. Attempting to connect to the db throws an SQLException (or others) so you put all of your logic (i.e. db connect, ResultSet retrieval) in your try. You catch the exceptions and in the finally you close the connection. This way you will always close the connection, no matter what happens in your try.
  • What is a PreparedStatement?
    • A PreparedStatement is a semi-formulated query with question marks (?) that can be set to certain values. For example, a preparedStatement can be "SELECT * FROM STUDENTS WHERE NETID=?" You can then set the ? to a string, integer, or other defined types. (more detail to be added here) Using a PreparedStatement helps in validating input. This way, it is more visible to the coder as to what each input should be. Though, you would still need to make sure that the field-to-be-inputted is a valid and well-formed field, it aids the validation process.
  • What is an OUTER JOIN?
    • If you have a table A and a table B where some entries in B are related to A, tableA(id, name, salary), tableB(id, workfloor), an Outer Join with A to B will get all entries in A and attributes in B where the id matches A.id. But if not, it'll just put empty values for entries not dually found in B.

UNIX questions

  • How do you search for a file in a filestructure (find / -name filename)
  • How do you search for a string in files in a filestructure (find . -exec grep "searchstring" '{}' \; -print)
  • How do you list processes (ps -ef)
  • How do you kill a process nicely (kill pid -15) Force kill a process (kill pid -9)
  • How do you see background processes (jobs)
  • How do you bring a background process back to the foreground (fg job id)
  • How do you show the last 100 lines of a file (last -100 file)
  • List the processes which are eating up a lot of RAM
  • How to restart Apache
  • How to use CVS or Subversion (checkout, add, commit, update..)
  • BONUS: What is a PHP cache? Why is it good? (A php cache holds snippets of your php files that have already been translated. This is similar to a browser cache except on the server side.)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.