Solved

Could Someone Help Me With This Question?

Posted on 2004-03-21
3
236 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven module vs maven project 3 73
Selenium docs api java index 3 67
Java class and jar 3 42
How to fix  socket closed error 11 28
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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:

733 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