Question

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!

Q3 Assume a static method in a Java class. Which of the following statements would cause the method to be erroneous? 2 Points

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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

Add a comment
Know the answer?
Add Answer to:
Good afternoon, I need assistance find the correct answer to the following question to an entry-level...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Good afternoon, I need assistance find the correct answer to the following multiple-choice questions to an...

    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...

    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...

  • CS0007 Good day, I am in an entry-level Java class and need assistance completing an assignment....

    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...

  • Predict the output of the following code : 12.[9 points] The following question consists of 3...

    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...

    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)...

  • I need help putting These in correct order. Java please rearrange the following code into a...

    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...

  • 1. What is an abstract method and why are they useful? Illustrate your answer using an...

    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...

  • the following is in java find the errors and answer the question what would the output...

    the following is in java find the errors and answer the question what would the output be if the program was functioning and the following was entered Obect-Orientated Programming Systems Languages Applications import java. Scanner: public class LabProgram { public static String create acconym String usssPhrase) { string total Acronym: intji: total Asconym "" for (1 == 0; j <user Phrass.length); ++j1) { if (i= usesPhrase.length0 - 1) { if (i=0) if (user Phrase.charAt(1) >= 65 & userPhrase.charAt()=90) { totalAcronym...

  • I ONLY need question 2 part C AND D answered...it is in bold. Please do not...

    I ONLY need question 2 part C AND D answered...it is in bold. Please do not use hash sets or tables. In java, please implement the classes below. Each one needs to be created. Each class must be in separate file. The expected output is also in bold. I have also attached the driver for part 4 to help. 1. The Student class should be in the assignment package. a. There should be class variable for first and last names....

  • I have Majority of the code written but I just need to implement the <,>,and =...

    I have Majority of the code written but I just need to implement the <,>,and = sign in the code. I have posted the instructions for the whole code. I will add what I have at the end. Objectives: Implement basic class concepts in Java Implement inheritance with super and sub-classes Implement basic polymorphism concepts Problem: The TARDIS has been infected by a virus which means it is up to Doctor Who to manually enter calculations into the TARDIS interface....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT