Final Flashcards
What is a constructor?
A constructor is a method that allows you to create objects from a class. You call the constructor by using the keyword new , followed by the name of the class, followed by any necessary parameters. Constructors are responsible for initializing the instance variables of the class.
How do you instantiate an object?
Instantiating an object consists of defining an object reference—which will hold the address of the object in memory—and calling a special method of the class called a constructor, which has the same name as the class.
What is default constructor?
A default constructor is a constructor which can be called with no arguments (either defined with an empty parameter list, or with default arguments provided for every parameter).
What is a “copy” constructor?
A copy constructor is a special constructor for creating a new object as a copy of an existing object.
What is an array?
An array is a sequence of variables with adjacent memory locations and of the same data type. The data type could be any primitive data type, such as int, float, double, byte, boolean, char, short, or long, or it could be a class.
How do you access elements of an array?
An element is accessed using the array name and a subscript, called an index, which refers to the element’s position in the array.
What is the difference between a Counter and an Accumulator?
Accumulators are used to keep a running total of numbers during successive passes through a loop, while a counter will be incremented by one and will be equal to the number of loop iterations
What is an overloaded constructor?
A method can be overloaded by defining another method with the same name but a different signature, that is, with a different number of parameters or with parameters of different data types.
What is the difference between a Static and a Non-Static method inJAVA language?
A “Static” method DOES NOT require instantiating an object to access it.A “Non Static” method requires instantiating an object to access it. Examples : Main and MATH methods
Describe the Program Development Cycle?
1) Design a solution to a problem (design a program)
2) Implement the solution (code the program )
3) Test the solution (test the program)
4) Fix the solution (debug the program)
What are the three basic operation in Boolean logic?
AND, OR, and NOT
What type of errors can you have?
SYNTAX ERRORS – Violations of the programming language rules.
LOGIC ERRORS – Also called run-time or execution errors.
They are errors in the sequence of the instructions in the
program.
What is instantiation?
The act of creating a new instance of an object.
What are variables?
Variables are memory locations used to store data.
What are parameters?
Parameters are values that are passed to another method when it is invoked by an event.
What’s the difference between pre and post unary operator?
The prefix versions increment or decrement the variable first, then the new value of the variable is used in evaluating the expression. The postfix versions increment or decrement the variable after the old value of the variable is used in the expression
What does the modulus % operator do?
In Java, the integer division (/) operator will calculate the quotient of the division, whereas the modulus (%) operator will calculate the remainder of the division.
Scanner class
import java.util.Scanner;
Scanner scan = new Scanner (System.in);
String arbitrary = scan.next ( );
Random class
import java.util.Random; Random random = new Random( ); int die = random.nextInt ( 6 ) + 1;
List Steps of the Machine Cycle.
a) FETCH instruction
b) DECODE instruction
c) EXECUTE instruction
d) STORE instruction
What is a Bit?
Bit- A bit (short for binary digit) is the smallest unit of data in a computer. A bit has a single binary value, either 0 or 1.
What are the three controls in any program?
Sequence, Selection, Iteration
Know the logical way records are read from a file:
Open file, Primingread, Loop until EOF, second read in loop and Close file after loop.
What is the difference between Procedural and Object Orientedprogramming?
A Procedural Language does NOT PERMIT to define OBJECTS.
Example: C Language, PASCAL
OO Language you can define objects using the Class construct.
Example: JAVA, C++