Question

QUESTION 1 Each class must be declared in its own .java file True or False? QUESTION...

QUESTION 1

  1. Each class must be declared in its own .java file

    True or False?

QUESTION 2

  1. The keyword this must always be explicitly used when referring to an object's instance variables and methods from within one of its non-static methods.

    True or False?

QUESTION 3

  1. When used in a class' main method the this keyword references the object representing the class itself.

    True or False?

QUESTION 4

  1. Accessor methods that test whether a condition is true or false are often called predicate methods.

    True or False?

QUESTION 5

  1. A class that holds references to objects of other classes as members demonstrates composition (a has-a relationship).

    True or False?

QUESTION 6

  1. The following code creates a new instance of the Pixel enum and assigns it to myPixel:

    enum Pixel {RED, GREEN, BLUE}

    // ...

    Pixel myPixel = new Pixel();

    True or False?

QUESTION 7

What does the following code display?

enum Pixel {RED, GREEN, BLUE}

// ...

public static void main(String args[]) {

for (Pixel px : Pixel.values()) {

System.out.print(px);

}

}

QUESTION 8

  1. A program might be terminated before the JVM's garbage collector has been executed.

    True or False?

QUESTION 9

  1. The following import statement allows the class that contains it to access all static members of the java.lang.Math class by their unqualified names (e.g.: double piVal = PI;)

    import static java.lang.Math.*;

    True or False?

QUESTION 10

  1. Variables with constant values (those that cannot be modified once initialized) are declared with the keyword ______.

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

1. False.

Each "public" class needs to be declared in its own file

2. True. This is the best way to do the code

3. False

main method is static, we cannot use this in that method

4. True

5. True

6. False

7.

Red

Green

Blue

8. True.

It can terminate explicitly

9. False we still need to use Math.PI

10. final

Add a comment
Know the answer?
Add Answer to:
QUESTION 1 Each class must be declared in its own .java file True or False? QUESTION...
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
  • Java Questions A class must implement at least one interface. Question 1 options: True False Question...

    Java Questions A class must implement at least one interface. Question 1 options: True False Question 2 (1 point) Abstract methods can be called. Question 2 options: True False Question 3 (1 point) Constructors Question 3 options: Are inherited but cannot be accessed Are inherited and can be accessed Are accessible but are not inherited Are not inherited and cannot be accessed Question 4 (1 point) We can instantiate an object from an abstract class. Question 4 options: True False...

  • Question 1 1 pts Which of the following is not a valid class name in Java?...

    Question 1 1 pts Which of the following is not a valid class name in Java? O MyClass MyClass1 My_Class MyClass# Question 2 1 pts Which of the following statements is False about instance variables and methods? Instance variables are usually defined with private access modifier. Instance variables are defined inside instance methods. Instance methods are invoked on an object of the class that contains the methods. A class can have more than one instance variables and methods. Question 3...

  • Part Two: Fill in the Blanks and True/False (24 total points - 2 points each) For...

    Part Two: Fill in the Blanks and True/False (24 total points - 2 points each) For each of the following, fill in the most appropriate word(s)phrase/solution in each blank 1) Keywords, identifiers and literals are all kinds of are simply groups of characters that are used for various purposes in a program. , which 2) The Java expression: 11 - 2 + 3 evaluates to 3) List the Java boolean (logical) operators in order from highest priority to lowest priority...

  • JAVA QUESTION 1 The value returned by a value-returning method can be saved for further calculation...

    JAVA QUESTION 1 The value returned by a value-returning method can be saved for further calculation in the program. True False QUESTION 2 To use a predefined method you must know the code in the body of the method. True False QUESTION 3 A formal parameter is a variable declared in the method heading (ie. it's signature). True False QUESTION 4 A local identifier is an identifier that is declared within a method or block and that is visible only...

  • [Java] PLEASE FIX MY CODE I think I'm thinking in wrong way. I'm not sure what...

    [Java] PLEASE FIX MY CODE I think I'm thinking in wrong way. I'm not sure what is wrong with my code. Here'e the problem: Write a class SemiCircle that represents the northern half of a circle in 2D space. A SemiCircle has center coordinates and a radius. Define a constructor: public SemiCircle(int centerX, int centerY, int theRadius) Implement the following methods: public boolean contains(int otherX, int otherY) returns true if the point given by the coordinates is inside the SemiCircle....

  • Once your UML diagram is complete implement the class naming the Java file MyInteger.java. Create another...

    Once your UML diagram is complete implement the class naming the Java file MyInteger.java. Create another Java file, a program named MyIntegerTester.java that tests all methods in the class. One technique is to write both classes at the same time. As much as possible you implement and test one method at a time. This minimized the amount of new code you have to look at when debugging a method. Only the Version 4.0 “tester” file will have main() method in...

  • In java Build a QueueInt class for integers that is compatible with the driver code below. The QueueInt should operate in a FIFO (first in, first out) fashion and implement the variables and methods a...

    In java Build a QueueInt class for integers that is compatible with the driver code below. The QueueInt should operate in a FIFO (first in, first out) fashion and implement the variables and methods also listed below: Data Members: Declare and initialize, as needed, the data item(s) you will need to manage a queue of integers. You may only use arrays and primitives for your instance and/or static variables (I,e You can’t use Java defined Queue / Stack / List...

  • A Java Problem. In this problem you are going write a class to model a traffic...

    A Java Problem. In this problem you are going write a class to model a traffic light that can cycle through colors, red, green, yellow. To do this, you will have to maintain the state of the traffic light. Maintaining state is one of the design pattern discussed in this week's lesson. The state of the TrafficLight indicates which light is lit. It changes every time the TrafficLight cycles. Specification TrafficLight will have a constructor that takes the x and...

  • Question 1 If a method is marked as protected internal, who can access it? Classes that...

    Question 1 If a method is marked as protected internal, who can access it? Classes that are both in the same assembly and derived from the declaring class. Only methods that are in the same class as the method in question. Internal methods can only be called using reflection. Classes within the same assembly, and classes derived from the declaring class Question 2 To avoid having to use fully qualified referenced classes, you could: Add a reference to the class....

  • The following code must be written and run with no errors in java eclipse Description of...

    The following code must be written and run with no errors in java eclipse Description of the code to be written: A resistor is an electronic part colour-coded with three coloured bands to indicate its resistance value. This program returns the resistance of a Resistor object instantiated with three Strings, representing the three colour bands of a real resistor. Start by creating an abstract class 'AbstractResistor' that implements the Comparable interface. This class should have the following three private methods:...

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
ADVERTISEMENT