Solved

Could Someone Help Me With This Question?

Posted on 2004-03-21
3
235 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
ID: 10644727
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
ID: 10645461
this looks like a question for the certification.
0
 

Author Comment

by:Roxanne25
ID: 10681596
Nope. :)  Was a homework question for a class.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

838 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