计算机代考 Graded Java Quiz

Graded Java Quiz
Quiz Instructions
The starter code for the MarkUs coding component can be found here (https://markus.teach.cs.toronto.edu/2022-09/courses/2/assignments/95/) .
Some questions in this quiz pertain to the starter code mentioned above, which you can download from MarkUs. Before starting this quiz, please make sure to download the code and have it open in IntelliJ. While not required, you may find it helpful to complete the coding component of the assessment before completing the timed quiz, as it will help you become familiar with the provided code.

Copyright By PowCoder代写 加微信 powcoder

Do NOT make any public piazza posts about the contents of this quiz or about the MarkUs code writing component. Asking or answering public piazza posts pertaining to this assessment will be investigated as an academic offence.
Lindsey will be holding some designated office hours (see the office hours page for the schedule) in which she will be available in case you would like to take the quiz at a time when someone will be available to provide timely clarifications about anything. If you find that anything is unclear, please make a note in your submission of how you interpreted the question and we can take that into consideration if you later decide to submit a remark request after grades are posted. Private piazza posts can also be made, but we will not be monitoring them closely, so don’t count on a timely response when completing the quiz.
Question 1 1 pts
Consider this class:
public class C {
private Object valueOfC;

AM Quiz: Graded Java Quiz
C var1 = new
False False
Question 2 1 pts
https://q.utoronto.ca/courses/278453/quizzes/288618/take 2/11
Decide if each ending of the following statement is true or false: When you try to create an instance of C by typing ”
(a) …Java automatically calls the constructor instead of
C ‘s constructor
(b) …Java automatically calls a constructor that calls the
constructor as well
(c) …it will not work because it is not possible to create instances of class C
(d) …the program will not compile (e) …the program will not run
(f) …Java will behave as though class C extends even though we didn’t explicitly say that we were extending
(g) … ‘s instance variable, , will have a default value of after the line of code is executed

10/14/22, 2:59 AM Quiz: Graded Java Quiz
If you comment out the constructor in the
class, IntelliJ will indicate that the code now contains an error in the ThreeInARowValidator class. Which of the following looks most like the error message you would see?
There is no constructor available in ‘ThreeInARowValidator’ Method is never used
Symbol not found
There is no default constructor available in ‘WinValidator’ Constructor is never used
ThreeInARowValidator
Question 3 1 pts
Assume that a class called X has a validate method described by this signature:
public boolean validate(Board board)
The following method signatures each describe a method you could also add to class X . You can assume that the program compiles before you add any of them. You can also assume that there is no code inside any of the methods that will prevent the program from compiling.
For each method signature, decide if the program will compile if you add a method with that signature to X , individually.
public boolean validate(Board board, String player)
The program will still co
https://q.utoronto.ca/courses/278453/quizzes/288618/take

10/14/22, 2:59 AM Quiz: Graded Java Quiz
https://q.utoron
public int validate(Board board)
The program will NOT
public boolean validate1(Board board)
The program will still co
public String validate(Board board, int player)
The program will still co
public String validate(Board board)
The program will NOT
Question 4 1 pts
Our goal is to include an argument in the constructor for a Player class of type int and then assign that argument’s value to an instance variable.
Decide for each code snippet if it does or does not accomplish this.
This accomplishes the
public class Player {
private int n;
public Player(int n){
this.n = n;
to.ca/courses/278453/quizzes/288618/take

10/14/22, 2:59
https://q.utoron
AM Quiz: Graded Java Quiz
This does NOT accomp
public class Player {
private int n;
public Player(int n){
This accomplishes the
public class Player {
private int num;
public Player(int n){
this.num = n;
This does NOT accomp
public class Player {
private int num;
public Player(int n){
num = this.n;
This does NOT accomp
public class Player {
private int num;
public Player(int n){
this.n = n;
to.ca/courses/278453/quizzes/288618/take

10/14/22, 2:59
https://q.utoron
AM Quiz: Graded Java Quiz
This does NOT accomp
public class Player {
private int n;
public Player(String n){
this.n = n;
Question 5 1 pts
For the purposes of the next two questions, imagine that Board has been turned into an abstract class with an abstract method called reset and direct subclasses PathBoard and GridBoard . You can also assume that any lines of code that would require updating in the code would be adjusted to accommodate this change.
For each of the following code snippets, decide if the program will compile and run or not, if the snippet is included in the main method of the XOGame class.
You can assume that the program otherwise compiles and runs. Consider each code snippet separately.
The program will NOT
List boards = new ArrayList<>();
boards.add(new PathBoard());
to.ca/courses/278453/quizzes/288618/take

10/14/22, 2:59
https://q.utoronto.ca/courses/278453/quizzes/288618/take 7/11
AM Quiz: Graded Java Quiz
The program will NOT
List boards = new ArrayList<>();
boards.add(new PathBoard());
boards.add(new GridBoard());
for(PathBoard b : boards)
b.reset();
The program will NOT
List boards = new ArrayList<>();
boards.add(new PathBoard());
boards.add(new GridBoard());
for(GridBoard b: boards)
b.reset();
The program will run.
List boards = new ArrayList<>();
boards.add(new PathBoard());
boards.add(new GridBoard());
for(Board b : boards)
b.reset();
The program will NOT
List boards = new ArrayList<>();
boards.add(new PathBoard());
boards.add(new GridBoard());
for(GridBoard g : boards)
g.reset();
for(PathBoard p : boards)
p.reset();
boards.add(new GridBoard());
for(Board b : boards)
b.reset();

10/14/22, 2:59 AM Quiz: Graded Java Quiz
Question 6 1 pts
Consider class Board and its subclass GridBoard . Suppose that both classes have a method with the following signature:
public boolean setBoard(int numPlayers)
Consider the following variable declaration:
Board currBoard = new GridBoard();
The following code will cause the program to execute the version of setBoard in the GridBoard class. Why? Select the most accurate reason.
boolean isSet = currBoard.setBoard(2);
Java always uses the most specific version of an instance method.
The type of the variable is Board . If the Board class did not have a setBoard method, Java would check any abstraction of the Board class to see if the method is inherited by Board. But since the Board class already had a setBoard method, Java checked its subclass to see if the method was overriden.
Java never uses a method if it has been overriden in a subclass.
The type of the variable is GridBoard, so Java executed the version of setBoard that was in the GridBoard class.
Question 7 0 pts
Explain your answer to the previous question.
Note: Your answer will only be graded if you did NOT get full marks on the previous question.
https://q.utoronto.ca/courses/278453/quizzes/288618/take

10/14/22, 2:59 AM Quiz: Graded Java Quiz
https://q.utoron
Additionally, you can also use this space to indicate any assumptions you made when answering any questions on this quiz ¡ª you can refer to what you wrote here if you later submit a remark request.
p 0 words
Question 8 1 pts
Some of the following lines of code either contain aliases for the same object or are explicit assignment statements that result in an alias being created for an existing object already referenced elsewhere. Select the list of line numbers that contains only those lines that contain aliases to the same object or create aliases through an assignment statement.
1. public class QuizQuestion {
2. Board board = new Board();
to.ca/courses/278453/quizzes/288618/take

10/14/22, 2:59
https://q.utoronto.ca/courses/278453/quizzes/288618/take 10/11
AM Quiz: Graded Java Quiz
lines 5, 12, 15, 16 lines 5, 11, 12, 15, 16 lines 5, 11, 15, 16 lines 11, 12, 14, 16 lines 5, 11, 12, 16 lines 11, 12, 14, 15, 16
4. public QuizQuestion (Board board) {
7. public Board getBoard() {
10. public void doStuff() {
11. Board b1 = board;
12. Board b2 = this.getBoard();
13. List boardList = new ArrayList<>();
14. boardList.add(new Board());
15. System.out.println(board.toString() + boardList.get(0));
16. System.out.println(board.toString() + b1.toString());
17. } 18.}
this.board = board;
return board;
Question 9 1 pts
type int called value from…
class, there is a private instance variable of
. The variable can be directly assigned a
a method in WinValidator .
the main method, which is located in
WinValidator
XOGame.java

10/14/22, 2:59 AM Quiz: Graded Java Quiz
a method in a class that is nested inside
WinValidator (Hint: you can try defining such an inner class to see if this works or you can refer to the reference on inner classes here (https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html) if you aren’t sure what it means to define one class inside of another.)
of type WinValidator
a class which has an instance variable
No new data to save. Last checked at 2:59am
Submit Quiz
https://q.utoronto.ca/courses/278453/quizzes/288618/take

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com