Solved

Could Someone Help Me With This Question?

Posted on 2004-03-21
3
232 Views
Last Modified: 2010-03-31
class SampleClass {
   int a;
   int b;
   AnotherClass q;

   public void sampleMethod()
   {
         int c = 1;
         a = c * 7;
         b = 32 + c * a;
   }
}

which of the following statements is true?

        'c' is a reference.
        'a' and 'b' are local variables.
        'a' and 'b' are declared as a primitive data type.
        'q' is declared as a primitive data type.

Having a bit of trouble with this one.... thanks in advance!
0
Comment
Question by:Roxanne25
3 Comments
 
LVL 5

Accepted Solution

by:
twobitadder earned 125 total points
Comment Utility
c. 'a' and 'b' are declared as a primitive data type.

primitive data types are int/long int/short int/char/boolean/float/double, (non-primitive can be any class composed of other classes and/or primitives - ie. a class is a non primitive data type).

-q isn't delcared as a primitive type because it is declared as a class.

-a and b are not local variables because they are declared outwith a method (local variables are declared inside a method and go out of scope after the method exits).

-depends on your definition of reference but c is declared as an int with the value one and so it holds '1' and does not refer to another object.
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
Comment Utility
this looks like a question for the certification.
0
 

Author Comment

by:Roxanne25
Comment Utility
Nope. :)  Was a homework question for a class.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
matchUp  challenge 9 71
Performance issue while iterating with streams 5 39
sumDigits  challenge 7 60
unix in java example 9 38
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now