0% found this document useful (0 votes)
4 views20 pages

Java Application Deployment Quiz

The document contains a series of quiz questions and answers related to Java bytecode, Java applications, XML, Maven, unit testing, and integration testing. It covers topics such as the characteristics of bytecode, components of the JDK, differences between HTML and XML, and the importance of unit tests. Additionally, it discusses Maven project creation, dependency management, and the use of test doubles in testing frameworks like Mockito.

Uploaded by

manvisingh2618
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
4 views20 pages

Java Application Deployment Quiz

The document contains a series of quiz questions and answers related to Java bytecode, Java applications, XML, Maven, unit testing, and integration testing. It covers topics such as the characteristics of bytecode, components of the JDK, differences between HTML and XML, and the importance of unit tests. Additionally, it discusses Maven project creation, dependency management, and the use of test doubles in testing frameworks like Mockito.

Uploaded by

manvisingh2618
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
Quizzes: Java Bytecode Quiz Question ‘Which of the following statements about Java bytecode are true? Bytecode is faster than machine code Java Virtual Machines can run programs written in bytecode on any device where they are installed. Bytecode must be stored in a file named after the java class that the bytecode describes. (Once you have a class flle, you use the |javae/ command on it to run It. Quizzes: Building Java Applications Question 1 of 2 Which of the following components can you find in the JDK? ¥) The Java Runtime Environment ¥) Ajava compiler v¥| The Java Standard Library AJava IDE Question 2 of 2 Match each type of Java Archive with its role @ These are the correct matches. Role Standard Java Application Cy Web Application PP WAR Android Application no ae Quiz Question What are the advantages of multi-tiered compilation? ¥]_ it compiles bytecode into machine code quickly for faster startup. YJ Itcan produce more optimized code than a standard compiler. It allows you to compile different kinds of programs. YJ It produces faster code the longer it runs. Question 1 of 3 What are some differences between HTML and XML. HTML is used for describing web pages and XML can be used for general v) applications like use, store, transmit, and display data. HTML has fixed set of tags where XML is extensible, can have any names on tags. HTML uses tags to define blacks and XML uses curly braces. Question 2 of 3 How do you define a list in XML © Byusing square brackets [ and J. Using repeating tags, similar to the list elements on HTML. @ vairetenent 16/1 By using a different name for each element in the list, like oO Question 3 of 3 Thinking about Attributes vs Elements, attach each property to the appropriate concept. @ These are the correct matches. Concept Properties Attributes - Repetition Ue a Attributes - Nested data erase ee) Elements - Repetition eure acc) Elements - Nested data Ou cd Question 1 of 2 What are the required elements on the project tag at the top level of Maven POM. [7] modelversion [¥] grouprd [¥] version projectid Question 2 of 2 How can you create a Maven project? Using the command vn archetype:generate and selecting an archetype as template. (¥] Creating the pom.xm1| and the directories manually. Running mvn package Question 1 of 4 What is the default folder where Maven store the dependencies? © ~/.m2jrepository © /roct/maven/dependencies © /maven3/repo Question 2 of 4 How do we add a dependency to our maven project? © By drag-and-dropping the dependency into the Maven project. Adding the dependency identifiers ( groupId, artifactId|and version) to © the dependencies section within a dependency tag to the [Link] file. © By including the Jak for that dependency in our /src/main/resources directory. Question 3 of 4 What is the purpose of test scope on dependencies? (© sve the dependency avaiable for unt and integration tests but not for production code. © Test that the dependency works © Test our program. Question 4 of 4 Why might your project could end up with two versions of the same dependency? © Because it was declared the [Link] in that way. @ Besse to dependencies have the same transitive dependency but with different versions. © Because the .m2 directory already downloaded the dependency. Quiz Question Select the correct statements about plugins Any settings in the section will be inherited by children poms. ¥] You can pass additional data to plugins using the | element. You can only configure Maven's core plugins in the | section. You can attach a plugin goal to a Maven phase using the element. Question 1 of 2 Match the modules keywords with their purpose @ These are the correct matches. Module Keyword Purpose exports CHER eke sca) Ce acct requires Coen ec Prec eS a pees eee) ord ‘opens Ce cd eee ee Cg reflection Question 2 of 2 Which statement describes each term? @ These are the correct matches. Term Classpath Module path Unnamed Module ‘Automatic Module Question 1 of 2 Why are Unit Tests important? Unit tests are required by law. Statement Vector ec cc Smee CT) BEL ue one Dee eases Cue RE) Ber tues ec Cee eu classpath. Amodule created when you Pee ere a a CTU os YJ] They help document the behavior of our code. ¥] They let us know if future changes break the functionality of our application. Unit tests help your application run faster. Question 2 of 2 Match each type of Assertion with its behavior. @ These are the correct matches. Behavior Assertion Fails if two values are not the same Fails if any element ina List is different Always fails f) Fails if the specified exception is not thrown Fails if the provided value is true Question 1 of 2 Which of these tests does the best job of testing if our addTwoNumbers method can add 6 to things: GRepeatedTest (10) public void addTwoNunbers_addsix_returnsValuePlussix(Repetition int input1 = [Link](); int input2 = 6; oO int expected = 6 + inputs ‘App app = new App(); [Link](expected, [Link](input1, @ @valuesource(ints = {1, 5, 108, 1000, 160000}) public void addTwoNunbers_addSix_returnsNumberPlusSix(int numbe int inputt = 6; oO Ant expected = nunber + 63 App app = new App()i [Link](expected, [Link] (number, ‘ameterizedTest (@Paraneterizedtest @Valuesource(ints = {1, 5, 108, 1000, 100000}) public void addTwoNunbers_addSix_returnsNunberPlussix(int nunbe int input = 65 Aint expected = nunber + 6; App app = new App(); [Link](expected, [Link] (number, (@ParameterizedTest (nam @csvsource({ "6, 5, 41", "6,47" "6, 100, 106", |, 1008, 1206" "6, 100000, 100006" “[{index}] {8} + {2} = {2}") vy public void addTwoumbers_addsix_returnsNumberPlusSix(int input App app = new App(); Assertions assertEquels(expected, [Link](input2, a" » 106", @, 1606", © 20, 102006" TwoNumbers, few App()s assertEquals(expected, app-addTwoNurbers(input1, input2)); sddSix_retuensNumberPlusSix(int input1, int input2, int exp rest public void addTwoNumbers_fiveandsix_returnsEleven() { int inputi = 5; int input2 = 6; oO int expected = 11; App app = new App(); Assertions assertEquals (expected, app-addTwoNumbers(input1, Question 2 of 2 Which step in the Unit Test Lifecycle would be good for each of these actions: @ These are the correct matches. Action Lifecycle Step Initializing the Class Under Test Establishing a Database Connection Deleting Files Created By a Test ‘Shut Down Connection to a Server Quizzes: Good Unit Tests and Code Coverage Question 1 of 2 What are some goals we should aim for when writing unit tests? Test many requirements in the same unit test so you can reduce the number of tests you write, Unit tests should focus on the expected behavior and leave boundary checking to the Quality Assurance team. Place as many lines into the @BeforeEach| and |@BeforeAll methods as you can, to keep your tests shorter, even if not all tests use those lines. Keep your unit test names short, so they're easier to read in the logs. (¥] Make sure to test all branching conditions in your tested method. Question 2 of 2 How much code coverage should we aim for? 50% 75% 90% 100% ®o0o0o0ood Enough to make sure we test all our requirements. 7) c o Quizzes: Test Doubles Question 1 of 2 Which test double can you use to fulfill each function? @ These are the correct matches. Function Test Double Keep track of which methods were called Spy Always return a hard-coded value esate) Provide a non-null object that 5 doesn't perform any behavior cle Allow you to customize the return Values for ditferentinput parameters Question 2 of 2 Why do we need to use Test Doubles at all? Sometimes we need to replace the class we're testing with a Fake so we can control its behavior. You don't understand all the requirements of a class, so you can use a Spy to figure them out. oO Verify the behavior of the tested class without relying on its dependencies performing particular actions. © Test doubles can be much faster than production implementations, s0 we should use test doubles to make our unit tests run faster. STs Quizzes: Mockito and Matchers Question 1 of 2 For which Test Doubles can a Mockito Mock perform the same behaviors? ¥] Dummy ¥] Stub ¥} Spy ¥| Mock Question 2 of 2 What's a reason you might use a Mockito Spy? © Youneed to verify that a certain method is called on a dependency. © You have to change the behavior of one of the methods on a dependency. © Youneed to verify that a certain method is called on the tested class. © You have to change the behavior of one of the methods on the tested class. Quizzes: Integration Testing Question 1 of 2 Sort the types of automated testing. @ These are the correct matches. Description Testing Type Scope: Narrow Number of Tests: Most aia Scope: Moderate Number of Tests: Some cee Scope: Broad ee Ta Mtr Question 2 of 2 ‘The list below contains some behaviors performed by Integration Tests and some behaviors performed by Unit Tests. Mark all the examples of Integration Tests. Calling [Link] (user) and then checking if the value was written to the database. v| _— Using a mock petRepository to test whether your [Link](cat) updates happiness level. Using WireMock to supply a value in response to an http request when J] storefrontservice calls the icecreamPriceAPT. checkCurrentPrice(flavor) | method. Verifying that the fooBarBazCat(int) method returns "qux" for multiples of 17 and "corge" for multiples of 31.

You might also like