Good afternoon,
I need assistance find the correct answer to the following question to an entry-level Java assignment as I am confused about how to find it.
Thank you!
Please comment if you have any doubt
Q3)
Ans: c) The method accesses a non-static attribute in
the same class
Reason : A static method can only
access static memeber but not non-static attribute. So the it will
be erroneous.
Not a), because the method can call another static
method
Not b), because the method can be called from another
non-static method
Not d), because the method can access static
attributes
Q4)
Ans: a) Class Person implements the toString
method
Reason: toString() method is used
to return string representation of the Object
Not b), because it won't return anything
Not c), because println method can be used to print
but the returned value won't be representation for the pbject
Not d), because bugs has nothing to do with it
Q5)
Ans: b) Useful for passing information when starting
the program
Reason: The argument is used to
pass command line arguments before starting the
program
Not a), because it is not useless
Not c), because it is not required to use strings in
program
Not d), because it is an array
Good afternoon, I need assistance find the correct answer to the following question to an entry-level...
Good afternoon,
I need assistance find the correct answer to the following
multiple-choice questions to an entry-level Java assignment as I am
confused about how to find it.
Thank you!
Q6 Method squareX is supposed to return the value of class attribute "x" squared, but I messed up :(. What did I overlook? 2 Points class Final private double x; public double squarex() { double x = Math.pow (X, 2); return x; } Variable occlusion O Variable shadowing Method overloading...
I am in an entry-level Java class and need assistance solving
questions 20-25 for a homework assignment. Any help is appreciated.
Thank you.
Q20 Read the code and answer the question 6 Points Read each of the following code snippets and determine if they are equivalent. I.e. they produce the same output. Q20.1 Are these snippets equivalent? 2 Points Snippet 1: int i=0; while (i<10) System.cut.print(i); i++; 1 Snippet 2: for(int i-0; i<10; i++) System.out.print(i); } Yes O No Q20.2...
Predict the output of the following code :
12.[9 points] The following question consists of 3 java files (TestPerson java Person javaa Name java). When TestPerson.java is compiled, write down write down the exact output of the class TestPerson ( public static void main(Stringl] args) f Person a new Person(new Name ("Superman)) Person b new Person(new Name("Ninja")); Person c new Person(new Name("Thor")); Person d new Person(new Name("Batman")); Person e new Person(new Name("Hulk")); Person f = new Person(new Name("Poson Ivy")); Person...
Please answer this question (JAVA)
Consider now the following code fragment: 1 public class Main public static void main(String args) Person p; 2 3 pnew Person [2]; for (int i 0; i < p.length; i++) 3 пеw Person("A", "B", "С"); System.out.println(p [0].toString ()); 5 plil 6 8 9 10 6. What is the value of 'p' after line 3? (a) Something like "Person@42gf32" (b) null (c) A memory location 7. What is the value of 'p' after line 4? (a)...
CS0007
Good day, I am in an entry-level Java class and need assistance
completing an assignment. Below is the assignment criteria and the
source code from the previous assignment to build
from. Any help would be appreciated, thank you in
advance.
Source Code from the previous assignment to build from shown
below:
Here we go! Let's start with me giving you some startup code: import java.io.*; import java.util.*; public class Project1 { // Random number generator. We will be using this...
QUESTION 7 10 points Save Answer Given is a java class 'lustrate'. What are the contents of the object 13 right after line 13 in the main method? publie class Illustrate publie atatie void main (Stringl argo private int x private static int y 0; public statie int count-0 public Illustrate0) 1. Illustrate 11 -new 1llustrate(3) 2. Illustrate 12·new Illustrate(5); Illustrate.incrementy public Illustrate(int a) 9. Illustrate.count 10 public Illustrate(Illustrate I) 12 13. Illustrate 13·new Illustrate(11); 14 15. Illustrate 14-13; 16....
1. What is an abstract method and why are they useful? Illustrate your answer using an example of where you might use an abstract method. 2. What is the difference between a static variable and a non-static variable? Given the example of a class representing Dogs, give an example of a variable that may be static and another that may non-static. 3. In Java, when you modify a String as shown in the code below, Java makes a new String...
I need help putting
These in correct order. Java
please rearrange the following code into a working program based on the expected output. HINT: Use JDoodle to help in verifying the expected output 3. String D books new String 3 System.out.printinfbooks[refsl)h Int ref while (z < 3) System.out.print("books #*): books [0] "Grapes of wrath"; class BookArrays f books [1] Wind"; "Gone With The public static void main (String I ares) int z 0; 22+1; ref- title[2] int [I title new...
In Java, Write a class encapsulating a restaurant,which inherits from Store. A restaurant has the following additional attributes: how many people are served every year and the average price per person. code the constructor, accessors, mutators, toString and equals method of the new subclass; also code a method returning the average taxes per year. You also need to include a client class to test your code for both the parent class and the subclass. Code for Store below(Super class aka...
Please answer all the questions
2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: "java program!"). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which...