Quiz 5: Testing Lifecycle, Unit Testing, Network Programming

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The client requests a connection to a server using the following statement: -Socket s = new Socket(ServerName port) -Socket s = serverSocket.accept(); -Socket s = serverSocket.getSocket(); -Socket s = new Socket(ServerName);

-Socket s = new Socket(ServerName, port);

The server listens for a connection request from a client using the following statement: -Socket s = new Socket(ServerName, port); -Socket s = serverSocket.accept(); -Socket s = serverSocket.getSocket(); -Socket s = new Socket(ServerName);

-Socket s = serverSocket.accept();

Analyze the following code: public class Test implements Runnable { public static void main(String[] args) { Test t = new Test(); } public Test() { Thread t = new Thread(this); t.start(); } public void run() { System.out.println("test"); } } -The program has a compilation error because t is defined in both the main() method and the constructor Test() -The program compiles fine, but it does not run because you cannot use the keyword this in the constructor -The program compiles and runs and displays nothing -The program compiles and runs and displays test

-The program has a compilation error because t is defined in both the main() method and the constructor Test()

What is the best way to release a thread object once you are done using it? -assign null to Thread variable -use stop() method of Thread class -use suspend() method of Thread class -use resume() method of Thread class

-assign null to Thread variable

Which method of Thread class is used to temporarily release time for other threads? -sleep -yield -pause -join

-yield

What is Unit Testing?

A unit test is a piece of a code (usually a method) that invokes another piece of code and checks the correctness of some assumptions afterward. If the assumptions turn out to be wrong, the unit test has failed. A "unit" is a method or function. A unit test is an automated piece of code that invokes a different method and then checks some assumptions about the logical behavior of that method or class under test. A unit test is written using a unit testing framework. It can be written easily and runs quickly. It can be executed, repeatedly, by anyone on the development team.

What is JUnit?

JUnit is a unit testing framework for Java Programming language.

How is Unit Testing different from refactoring?

My ans: Unit testing is testing the program with different methods, checking for bugs. Refractoring is done after you are done testing and changing your program to work. Refractoring would be rewriting the working code. Refactoring can be done after writing several tests, or after each test. It is the act of changing a piece of code without changing its functionality. If you've ever renamed a method, you've done refactoring. If you've ever split a large method into multiple smaller method calls, you've refactored your code. It still does the same thing; it's just easier to maintain, read, debug, and change.

What is Test Driven Development (TDD)?

Test Driven Development is vastly different than "classic" development. You begin by writing a test that fails, then move on to creating the actual production code, and see the test pass, and continue on to either add functionality, refactor your code, or to create another failing test.

What is a Test Fixture?

Tests need to run against the background of a known set of objects. This set of objects is called a test fixture.


संबंधित स्टडी सेट्स

RN Nursing Care of Children 2016 BB

View Set

Exam: 02.08 Government Regulation

View Set

BLAW 2nd MIDTERM REVIEW QUESTIONS

View Set

MIS - Final Exam - Quizzes and Test

View Set

ATI Engage Fundamentals: Vital Signs

View Set

CIT 15 Chapter 12 Technology in Action 16e Fresno City College Fall 2019

View Set