Week 1 Quiz

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Git commit workflow Order the operations for a sensible workflow in Git. <code>git clone</code> make changes to files <code>git add</code> <code>git commit</code> <code>git push</code>

<code>git clone</code> make changes to files <code>git add</code> <code>git commit</code> <code>git push</code>

Which of the following statements is true about Java 8 lambda expression? Using lambda expression, you can refer to final variable or effectively final variable (which is assigned only once). Lambda expression throws a compilation error, if a variable is assigned a value the second time. Both of the above. None of the above.

( Using lambda expression, you can refer to final variable or effectively final variable (which is assigned only once). Lambda expression throws a compilation error, if a variable is assigned a value the second time.) Both of the above. Explanation : Both of the above options are correct.

Eclipse supports JUnit integration using its plugin. true false

true Explanation : Eclipse supports JUnit integration using its JUnit plugin.

Functional interfaces have a single functionality to exhibit. false true

true Explanation : Functional interfaces have a single functionality to exhibit.

JUnit provides Assertions for testing expected results. true false

true Explanation : JUnit provides Assertions for testing expected results.

Interfaces and abstract classes are associated with Abstraction Encapsulation Inheritance Polymorphism

Abstraction

A static method can Only be called from a static method Can only be called if at least one instance of its class exists in the program Cannot be overloaded Be called even if no instances of its class exist in the program

Be called even if no instances of its class exist in the program

What is the root interface of the Collections API? Collections List Collection Throwable

Collection

Which of the following is Faster, StringBuilder or StringBuffer? StringBuilder StringBuffer Both of the above. none of the above

StringBuilder Explanation : StringBuilder is faster than StringBuffer.

What are Wrapper classes? These are classes that allow primitive types to be accessed as objects. These are classes that wraps functionality of an existing class. Both of the above. None of the above.

These are classes that allow primitive types to be accessed as objects. Explanation : These are classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc.

What is Maven? A build automation and project management tool A unit testing framework A database connectivity framework for Java None of the above

A build automation and project management tool

What is Abstraction in Object Oriented Programming? A language concept that attempts to handle complexity by hiding unnecessary details from the user. A language mechanism that facilitates the reduction of data across multiple objects. A language construct that details the use case of public methods. A style of language that replaces english keywords with pictographs.

A language concept that attempts to handle complexity by hiding unnecessary details from the user.

What is the string pool? A location in memory where all strings are stored. A location in memory where strings referenced as literals in an application are stored. Java does not feature a string pool. A location for strings in the stack.

A location in memory where strings referenced as literals in an application are stored.

What is the Collections class? The parent class of List and Set. A utility class with useful static methods. The parent class of List, Set, and Map. A class for creating collection instances.

A utility class with useful static methods.

What is Git? A version control tool A build automation tool An automation server A container manager tool

A version control tool

What class of objects can be declared by the throws clause? Exception Error Event Object RuntimeException

Exception Error RuntimeException

An unchecked exception must be handled with a try/catch block or a throws declaration in order for the code to compile. TRUE Explanation : This is the case for checked exceptions. FALSE Explanation : Unchecked exceptions are not checked for at compile time. They will still crash your application if encountered at runtime however.

FALSE Explanation : Unchecked exceptions are not checked for at compile time. They will still crash your application if encountered at runtime however. (true is the case for checked exceptions.)

RuntimeException and its subclasses are checked exceptions. False True

False

A class always has a default constructor. True False

False Explanation : It is not mandatory to have a default constructor in a class.

Is it necessary that each try block must be followed by a finally block? True. False.

False. Explanation : It is not necessary that each try block must be followed by a finally block. It should be followed by either a catch block or a finally block.

Garbage collection can be forced by Using the gc() method Calling the finalize() method It can never be forced. None of the options 3

It can never be forced.

What is inheritance? It is the process where one object acquires the properties of another. Explanation : It is the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order. inheritance is the ability of an object to take on many forms. inheritance is a technique to define different methods of same type. None of the above.

It is the process where one object acquires the properties of another Explanation : It is the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order.

Which of the following is true about Maven? Maven is a project management and comprehension tool. Maven provides developers a complete build lifecycle framework. Both of the above. None of the above.

Maven is a project management and comprehension tool. Maven provides developers a complete build lifecycle framework. Both of the above. Explanation : Maven is a project management and comprehension tool. Maven provides developers a complete build lifecycle framework.

Which of the following is true of the StringBuilder class? It is safe to use in multi-threaded environments. It extends the String class. The class allows you to use the appendString() method to mutate a string. None of the above.

None of the above. Explanation : StringBuilder is not thread-safe, so it is not safe to use in multi-threaded environments. Explanation : The String class is a final class, which means that you cannot extend it. Explanation : There is no such method "appendString() " on the StringBuilder class.

Creating many objects while not allowing any to be cleaned up by garbage collection will create a memory leak and may eventually result in: StackOverflowError StackOverflowException OutOfMemoryError OutOfMemoryException

OutOfMemoryError

What is polymorphism? Polymorphism is a technique to define different objects of same type. Polymorphism is the ability of an object to take on many forms. Polymorphism is a technique to define different methods of same type. None of the above.

Polymorphism is the ability of an object to take on many forms. Explanation : Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.

Which access modifier would encapsulate data? Public Private Abstract Static

Private

It is not possible to instantiate objects of an abstract class TRUE FALSE

TRUE

TDD What is test-driven development? The process of writing tests first before writing the application code, then ensuring the tests pass The process of writing tests at the end of development, before the product is put into production The process of having end users test out the application and report bugs The process of automating deployment of the application to a server and then testing it out

The process of writing tests first before writing the application code, then ensuring the tests pass

Which of the following describes the Singleton pattern correctly? This pattern creates object without exposing the creation logic to the client and refer to newly created object using a common interface. In this pattern an interface is responsible for creating a factory of related objects without explicitly specifying their classes. This pattern involves a single class which is responsible to create an object while making sure that only single object gets created. This pattern is used when we want to pass data with multiple attributes in one shot from client to server.

This pattern involves a single class which is responsible to create an object while making sure that only single object gets created. Explanation : Singleton involves a single class which is responsible to create an object while making sure that only single object gets created.

Deletion is faster in LinkedList than ArrayList. True. False.

True. Explanation : Deletion in linked list is fast because it involves only updating the next pointer in the node before the deleted node and updating the previous pointer in the node after the deleted node.

Use of generics in Java allow for reusable code with generic typing while also providing Type Safety Type Casting Method-level testing Thread-safe behavior

Type Safety

Encapsulation ensures that... classes expose only certain fields and methods to other classes for access. Classes are able to inherit functionality from other classes. Classes desginate certain methods to be implimented by sub classes.

correct: classes expose only certain fields and methods to other classes for access. Inheritanceis Classes are able to inherit functionality from other classes. abstract methods. Is: Classes desginate certain methods to be implimented by sub classes.

Which of the following 'for' loops are syntactically correct and will not cause an infinite loop? for (Integer i : Integer j) {} for (i>10) {} for ( ; ; ) {} for (int i=10; i<0; i--) {}

for (int i=10; i<0; i--) {}

How do you create a new branch in Git? git checkout -b <newBranch> git checkout -n <newBranch> git checkout -nb <newBranch> git checkout <newBranch>

git checkout -b <newBranch>

What is the package for JUnit? java.junit org.junit javax.junit org.oracle.java.junit java.test.unit

org.junit

Which of the following is a valid constructor of class Animal? public void Animal() public Animal(int a, int b) public int Animal(int a, int b) private void Animal(int a, int b)

public Animal(int a, int b)

What is the standard signature for the main method? public static void main(String[] args) public static void main() public void static main(String[] args) public void main(String[] args)

public static void main(String[] args)

Which of the following uses of variable arguments is syntactically correct? Choose all that apply. public void someMethod(int...a, int b){...} public void someMethod(int...a, int...b){...} public void someMethod(int a, int...b){...} public void someMethod(int...a){...}

public void someMethod(int a, int...b){...} Explanation : A variable-length parameter must be the last parameter listed. It is perfectly acceptable to specify other parameters as long as the variable-length parameter comes last. public void someMethod(int...a){...} Explanation : There is only parameter in this case, so the variable-length parameter is the last parameter by default, which makes this use legal.

Which method must be implemented by all threads? wait() start() stop() run()

run() Explanation : All threads must implement the run() method.

Which of the following describes Unit Testing? (Choose the best answer) writing small programs to check the input to a component against a known output and verifying the results Explanation : Correct. the process of testing a group of components using interfaces or classes Explanation : Incorrect. the process of testing code when you know or have access to the internal workings and structure of a program Explanation : Incorrect. the process of testing code when you don't know or don't have access to the source code Explanation : Incorrect.

writing small programs to check the input to a component against a known output and verifying the results


Ensembles d'études connexes

Anatomy and Physiology Chapter 3 Brief: Tissues

View Set

Equation of a Tangent Line Practice

View Set

ADVANCED ACCOUNTING II - Chap 12

View Set

Case study compound fracture (preschooler)

View Set

Radical Reconstruction, Presidential Reconstruction, Andrew johnson, knights of labor

View Set