LCCC Course CIS 210 - Java Programming

Java Fundamental Structures, Concepts & Logic Worksheet

Define the following and give an example of each.

Word/Concept Definition Example

primitive data types

 
(list 5 types)

object

   

class

   

identifier

   

instance variable

   

declaration

   

instantiation

   

assignment

   

method

   

condition

   

statement

   

interface

   

information hiding

   

qualified name

   



Determine the final value of the variable.

int x = 1; int x = 4; int x = 4;
x++; while (x < 7) if (x == 6)
x+=2; {   {  
    x++   x = 3;
  }   }  
         
int x = 14; for (int j=2; j<4; j++) for (int y = 10; y > 1; y++)
x = x % 3; {   {  
x--;   int x = x + j;   y = y - 1;
  }   }  
        (gotcha)

 

 

Reference Answers

primitive data types (at least 5) - pre-defined java information ( int, boolean, double, char, float, long, byte, etc.)

object - The "thing" created in the computer's memory that is described by a class. Objects contain field (or instance) variables and methods.

class - The program that is written in Java that describes objects by declaring and instantiating variables and using (or calling) methods.

identifier - The name a programmer chooses to give to a class, variable, or method. Examples: PetRock, side, main()

instance variable - An identifier that refers to a memory location that holds data/information (i.e. a noun or ingredient)/

declaration - When a programmer gives a variable a name and a type (ex. String name). Also, a method is declared when it is given a method header (name) and its body. Example: public void eat {...}

instantiation - A programmer uses the reserved word "new" with a constructor to create an object in the computers memory. Example: new CyberPet();

assignment -A programmer uses the "=" to give a variable a value (ex. x = 5;)

method - A function, action, verb, or set of instructions that use and manipulates variables.

condition - A test that returns either True or False, usually inside an "if" or "for" statement and in parenthesis. Ex. if (score > 90)...

statement - A single java command that ends in a semicolon Ex. System.out.println("hello");

interface - Anything that is public in a class. Usually the methods of a class. Can be accessed outside the class. As opposed to private which cannot be accessed outside the class. Use of private variables is called "information hiding."

qualified name - Using the dot-notation to go inside an object to access the public features (methods). Ex: pet1.eat()

int x = 1; int x = 4; int x = 4;
x++; while (x < 7) if (x == 6)
x+=2; {   {  
    x++   x = 3;
  }   }  
x=4   x=7   x=4
int x = 14; for (int j=2; j<4; j++) for (int y = 10; y > 1; y++)
x = x % 3; {   {  
x--;   int x = x + j;   y = y - 1;
  }   }  
x=1   x=5   infinite loop

 

www.lc.edu

Last Updated: January, 2011