Final Flashcards

1
Q

What is a constructor?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you instantiate an object?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is default constructor?

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a “copy” constructor?

A

A copy constructor is a special constructor for creating a new object as a copy of an existing object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an array?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you access elements of an array?

A

An element is accessed using the array name and a subscript, called an index, which refers to the element’s position in the array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between a Counter and an Accumulator?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an overloaded constructor?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between a Static and a Non-Static method inJAVA language?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe the Program Development Cycle?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the three basic operation in Boolean logic?

A

AND, OR, and NOT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What type of errors can you have?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is instantiation?

A

The act of creating a new instance of an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are variables?

A

Variables are memory locations used to store data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are parameters?

A

Parameters are values that are passed to another method when it is invoked by an event.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What’s the difference between pre and post unary operator?

A

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

17
Q

What does the modulus % operator do?

A

In Java, the integer division (/) operator will calculate the quotient of the division, whereas the modulus (%) operator will calculate the remainder of the division.

18
Q

Scanner class

A

import java.util.Scanner;
Scanner scan = new Scanner (System.in);
String arbitrary = scan.next ( );

19
Q

Random class

A
import java.util.Random;
Random random = new Random( );
int die = random.nextInt ( 6 ) + 1;
20
Q

List Steps of the Machine Cycle.

A

a) FETCH instruction
b) DECODE instruction
c) EXECUTE instruction
d) STORE instruction

21
Q

What is a Bit?

A

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.

22
Q

What are the three controls in any program?

A

Sequence, Selection, Iteration

23
Q

Know the logical way records are read from a file:

A

Open file, Primingread, Loop until EOF, second read in loop and Close file after loop.

24
Q

What is the difference between Procedural and Object Orientedprogramming?

A

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++

25
Q

DESIGN

A
Many different techniques are used to design methods in new software. Top-down development and modular design are most common. 
Tools include flowcharts, pseudo-code, storyboards, and Universal 
Modeling Language (UML). 
Flowchart – Pictorial representation of the sequence of instructions in a 
program. 

Pseudo-code – English-like statements representing the sequence of
instructions in a program.

26
Q

CODE

A

The program development cycle’s code phase includes translating a softwaredesign into a particular language, and then entering that language on the
computer.
The code is translated using an INTERPRETED or COMPILER

INTERPRETED – Translates and Executes ONE instruction at a time.
Example: BASIC Language

COMPILER – Translates ALL Instructions as a BLOCK and produces an 
EXECUTABLE file (.exe)
27
Q

TEST

A

Does the new method do what it is supposed to do? This is known as a testfor correctness. Tests for correctness measure whether the program meets the original specifications.

A unit test checks to see if a method works as expected all by itself.

An integration test checks to see if a method
works in combination with other methods

28
Q

DEBUG

A

The causes of any problems discovered during testing need to be isolated. Here unit tests are most helpful. Once you know the cause, you can develop a plan for fixing the problem, modify the necessary methods, and then test again

29
Q

What does a switch statement look like?

A

Switch (variable to find) {
case var1: System.out.print(“this is sample output”);
break;
case var2: System.out.print(“this is more sample output”);
break;
case var3: System.out.print(“starting to get it? sample sample”);
break;
default: System.out.print(“this like else in if statement”);
break;
}

30
Q

What is a Byte?

A

A byte is a unit of data that is eight bits long. A byte is the unit most computers use to represent a character such as a letter, number, or typographic symbol (for example, “g”, “5”, or “?”).

31
Q

What is ASCII?

A

ASCII (American Standard Code for Information Interchange) is the most common format for text files in computers and on the Internet. In an ASCII file, each alphabetic, numeric, or special character is represented with a 7-bit binary number (a string of seven 0s or 1s). 128 possible characters are defined.

32
Q

How do you use the “?:” conditional operator?

A

String outcome = ( number % 2 == 0 ? “even.” : “odd.” );

System.out.println( number + “ is “ + outcome );

33
Q

Another example use of “?:” conditional operator…

A

class ConditionalDemo2 {

public static void main(String[] args){
    int value1 = 1;
    int value2 = 2;
    int result;
    boolean someCondition = true;
    result = someCondition ? value1 : value2;

    System.out.println(result);
}
34
Q

Show another example of Switch Statment.

A
public class SwitchDemo {
    public static void main(String[] args) {
    int month = 8;
    String monthString;
    switch (month) {
        case 1:  monthString = "January";
                 break;
        case 2:  monthString = "February";
                 break;
        case 3:  monthString = "March";
                 break;
        case 4:  monthString = "April";
                 break;
        case 5:  monthString = "May";
                 break;
        case 6:  monthString = "June";
                 break;
        case 7:  monthString = "July";
                 break;
        case 8:  monthString = "August";
                 break;
        case 9:  monthString = "September";
                 break;
        case 10: monthString = "October";
                 break;
        case 11: monthString = "November";
                 break;
        case 12: monthString = "December";
                 break;
        default: monthString = "Invalid month";
                 break;
    }
    System.out.println(monthString);
} }