• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off

Card Range To Study



Play button


Play button




Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

79 Cards in this Set

  • Front
  • Back

A program that connects the byte-code of the classes needed to run a Java program ?

Class Loader

The arrangement of wordsand punctuations that are legal in alanguage, the grammar rules of alanguage


The meaning of thingswritten while following the syntax rulesof a language


Bits in a byte


Bytes in a boolean


Bytes in a char


Bytes in a byte


Bytes in a short


Bytes in an int


Bytes in a long


Bytes in a float


Bytes in a double


What is the print f format + "%.

x = Number to right justify

y = Number of digits to display after decimal place

c = The type output representation

Format specifiers :







d = Decimal integer

f = Fixed-point floating point

e = Enotation floating point

g = general floating point

s = string

c = character

How to create a Scanner object for getting input from console ?

new java.util.Scanner(System.in)

the next... methods of a Scanner object ?





and so on

Does the nextLine method of a Scanner object remove and discard the delimiter?


How to change the delimiter of a Scanner class ?


How to specifically avoid short circuiting using the AND or OR operators

Use & instead of &&

Use | instead of ||

What is the syntax of a switch statement

Switch(a) :


case 1 :



case 2:






What are the two multi-way branching loops

The nested "if else-if" and "switch"

What are the three types of loops in java ?


Check condition then execute


Execute then check condition


Initialize, Compare, Execute, then execute statement

What do the break and continue commands do ?

break: Exits the innermost for, while or do while loop.

Continue: Skip to the next iteration of the innermost loop, skipping and code below it. In the case of a for loop, control goes to the update part.

How would you label a loop ?



}while(a >1);

Write a do while loop





Don't forget the semicolon!

In a for loop how would you have multiple initialization ?

for(int i = 0, int j = 1; i<0 && j >2; i++){


Use a comma

How to use the assert command

assert Boolean_Expression;

What kind of scope does java have?

Block scope

When must the this parameter be used ?

When a local variable has the same name as an instance variable in the calling object.

What methods does java expect all classes to have ? And write their method definitions.

String toString()

boolean equals(classname object)

What does information hiding mean ?

Information hiding is the practice of separating howto use a class from the details of its implementation using private, public,protected modifiers.

What does Encapsulation mean ?

Encapsulation means that the data and methods ofa class are combined into a single unit (i.e., a classobject), which hides the implementation details

What is Overloading ?

Overloading is when two or more methods inthe same class have the same method name.

In general no two methods can have the same combination of method name and parameter lists.

Does Java permit methods with thesame name and different return typesin the same class ?


What does the StringTokenizer class do ?

The StringTokenizer class is used torecover the words or tokens in a multi-wordString.

– You can use whitespace characters to separateeach token, or you can specify the charactersyou wish to use as separators

– In order to use the StringTokenizer class, besure to include the following at the start of the file:import java.util.StringTokenizer;

StringTokenizer is LEGACY. User String.split() instead.

Explain the following methods of String Tokenizer :



nextToken(String delimiters)


hasMoreTokens() : Tests if there are more tokens available from this tokenizer's string.

nextToken() : Returns the next token from this string tokenizer.

nextToken(String delim)Returns the next token in this string tokenizer's string.

countTokens() :

Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.

Can a class static method call non static methods within the same class ?


Does a java static method have a this variable ?


What methods and variable can a static method access ?

Other static variables and other static methods.

What limitations are there on static variables ?

A static variable should always be defined private, unless it is also a defined constant

The value of a static defined constant cannot be altered, therefore it is safe to make it public

In addition to static, the declaration for a static defined constant must include the modifier final, which indicates that its value cannot be changed

What are some methods in the java math class ?

// Return smallest whole number greater than or equal to argument

- Ceil(a)

// opposite

- floor(a)


- Min( a, b)

- Pow(base, exponent)

- abs()

// To nearest whole number
- round()

What are wrapper classes ?

Wrapper classes are classes which emulate and extend the functionality of the primitive types :


What is Boxing ?

Boxing: the process of going from a value of a primitive type to an object of its wrapper class–

To convert a primitive value to an "equivalent" class type value, create an object of the corresponding wrapper class using the primitive value as an argument

The new object will contain an instance variable that stores a copy of the primitive value

Why is boxing important ?

Because primitive types are not classes.. Therefore they cannot be used with some of the java standard library (importantly Generics).

For Example, java.util.Vector<>

What is Boxing and how to achieve it ?

Unboxing: the process of going from an object of a wrapper class to the corresponding value of a primitive type

What is unboxing and how is it achieved ?

Unboxing: the process of going from an object of a wrapper class to the corresponding value of a primitive type

Unboxing is achieved by a call to intValue,charValue,doubleValue, etc etc

What is automatic boxing and unboxing ?

Instead of creating a wrapper class object using the new operation (as shown before), it can be done as an automatic type cast:Integer integerObject = 42;

Instead of having to invoke the appropriate method (such as intValue, doubleValue, charValue, etc.) in order to convert from an object of a wrapper class to a value of its associated primitive type, the primitive value can be recovered automaticallyint i = integerObject;

What are some use full constants in the wrapper classes ?

For example, Integer.MAX_VALUE,Integer.MIN_VALUE, Double.MAX_VALUE, Double.MIN_VALUE, etc.

How would you parse a string as a type using a wrapper class ?

Wrapper classes have static methods that convert a correctly formed string representation of a number to the number of a given type

The methods Integer.parseInt,




convert a correctly formed string into the PRIMITIVE TYPE

How would you represent a primitive type as a string ?

1 - Either box the primitive type and then call toString() on the object.

2 - Use the static method which will take a primitive type and convert it into a string. For example : Integer.toString(2) will give a string "2"

What usefull methods does the Character wrapper class have ?









Are java parameters in methods call by value or call by reference ?


However variables pointing at classes behave as if they are call by reference because this variables are behind the scenes actual references.

What is the "null" value in java

The null value denotes a lack of a class. For example one can do String s= null. Which basically means that s is currently not holding any object.

What does the == operator do in this statement;

object a == object b ?

The == operator only checks that two class type variableshave the same memory address

What is an immutable object

A class that contains no methods (otherthan constructors) that change any of thedata in an object of the class is called animmutable class

Explain deep copy versus shallow copy

A deep copy of an object is a copy that, withone exception, has no references incommon with the original– Exception: References to immutable objects areallowed to be shared.

Any copy that is not a deep copy is called ashallow copy– This type of copy can cause dangerous privacyleaks in a program

Give 3 ways to initialize and declare an array

int[] myIntArray = new int[3];

int[] myIntArray = {1,2,3};

int[] myIntArray = new int[]{1,2,3};

How do you determine the length of an array ?

if int[] a = new int[]{1,2,3,4};

then the length is a.length

What are arrays in java ? Primitive types or references types ?

Reference Types

What does the statement below do :

String[] s = new String[20];

Creates a new array of strings of length 20. each of the elements in the array will be a null variable, NOT an empty string object.

What type of array is the args parameter of the main method

the main method looks like :

public static void main(String[] args){}

So a String array.

Where can the for-each loop apply ?

The standard Java libraries include a number ofcollection classes– Classes whose objects store a collection of values. Collection is an interface.

This kind of loop can cycle through each element ina collection even though the elements are notindexed

What is the syntax for a for each loop

for( Type i : Collection){}

Give a simple example of defining an enumerated type ?

And then access the enum

public enum etype{Value1,Value2};

etype a = etype.Value1;

Given the following :

enum Workday{Monday,Tuesday,Wednesday};

Workday z = Workday.Monday;



The first line would print out "Monday"

The second line would also print out "Monday"

What does the values() method of an enum do ?

It returns an array whose elements are the values of theenumerated type given in the order in which the elementsare listed in the definition of the enumerated type

For example the following :

enum[] a = enum.values();

How can enums be used in a switch statement and what is the syntax ?

What is an important caveat ?

given enum color{RED,BLUE,GREEM};

color Z = color.RED;

switch (z):


case RED:





What is a co variant return type ?

Ordinarily, the type returned may not bechanged when overriding a method

However, if it is a class type, then thereturned type may be changed to that of anydescendent class of the returned type

This is known as a covariant return type –

Covariant return types are new in Java 5.0; theyare not allowed in earlier versions of Java

Can the Access Permission of anOverridden Method be changed ?

Explain how ?

The access permission of an overriddenmethod can be changed from private in thebase class to public (or some other morepermissive access) in the derived class

However, the access permission of anoverridden method can not be changed frompublic in the base class to a more restrictedaccess permission in the derived class

Can a child both overload and override an inherited method at the the same time ?

Yes. Both the overriden method and overloaded method will exist in the child.

If only the method is overloaded then the inherited default method will also be in the child !

How can you prevent a class from being extended ?

Put the final modifier in the class header.

How can you prevent a method from being extended ?

Put the final modifier in the method header.

How can you prevent a method or variable from being inherited ?

Making that variable of method private.

How would you make a a method heritable but not capable of being overridden ?

Placing public or protected in the header along with final.

How can a class prevent its children from inherting its methods or variables

By using the private keyword

How can a class prevent the public from accessing its objects and variables but still allow children to inherit ?

Use the protected modifier.

What are some rules of using the super constructor ?

A call to super must always be the firstaction taken in a constructor definition

An instance variable cannot be used as anargument to super

If no super constructor is specifically invoked then the default constructor will be invoked.

During construction of a child - calling this before calling the super constructor is legal as long as the call to the this constructor first calls a super as its first action. Is this legal ? Give an example ?

Yes legal. Look at parent.java and child.java

What unchecked exceptions might the next...() methods of the scanner class throw and if import statements are required to catch them write them down.