Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Could Someone Help Me With This Question?

Posted on 2004-03-21
3
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
twobitadder earned 500 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

719 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