Week 1 - Programming Foundations - Learn basic programming constructs using Java Flashcards

1
Q

What is a Full Stack Developer?

A

Full-stack developers straddle two separate development domains: the front end and the back end.
Those knowledgeable in both front end and back end are called full stack developers, meaning they are well versed in both disciplines.

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

What is a front-end developer?

A

They work to optimize the visible parts of an application for web browsers and mobile devices.
Front end platforms are usually built with HTML, CSS, and JavaScript; however, they can also be made via pre-packaged code libraries or content management systems like WordPress.

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

What is a back-end developer?

A

refine the software code that communicates with servers, databases, or other proprietary software that conveys information to front end interfaces

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

What class is used to read from the console

A

Scanner class

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

what do the following read?
nextBoolean()
nextByte()
nextDouble()
nextFloat()
nextInt()
nextLine()
nextLong()
nextShort()

A

Reads a boolean value from the user
Reads a byte value from the user
Reads a double value from the user
Reads a float value from the user
Reads a int value from the user
Reads a String value from the user
Reads a long value from the user
Reads a short value from the user

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

Java syntax to input an object and hold the string input?

A

Scanner sc = new Scanner(System.in);
String name = sc.nextLine();

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

What is the Scanner class used for?

A

Parsing input from text into primitives and strings, from a File or InputStream

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

Who invented Java?

A

Java was invented at Sun Microsystems by a team led by James Gosling. It was first released in 1995.

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

Who currently maintains Java?

A

Java is currently owned and maintained by the Oracle Corporation, which acquired Java when it acquired Sun Microsystems in 2010.

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

Why Java? What are the advantages?

A

Java is a high-level, compiled, strongly typed object-oriended programming (OOP) language. The advantages of Java are many: it is platform independent, has a C-language inspired syntax, provides automatic memory management, has an extensive built-in runtime library, is supported by the Oracle corporation, and has a rich open source community

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

What is “object-oriented”?

A

It has the constructs of classes and objects built into the language. It also allows us to use various principles of object-oriented programming.

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

What are classes?

A

They are the blueprints for how to create objects that contain a certain state - which is represented by fields (variables) - and behavior - which is defined via methods.

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

What are objects?

A

They are instances of class definitions. Each object has an identity, a behavior, and a state. They are logical entities.

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

Java is not 100% object-oriented because _____

A

it still has primitive values

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

What are the 8 primitive values?

A

byte: an 8-bit integer value.
short: a 16-bit integer value.
int: a 32-bit integer value.
long: a 64-bit integer value.
float: a single-precision 32-bit floating point value.
double: a double-precision 64-bit floating point value.
boolean: a true/false value.
char: a 16-bit Unicode character value.

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

Why are primitive values “primitive”?

A

These types are called “primitive” because they are not objects; they do not have methods or attributes like objects do. Instead, they are simple values that can be assigned, compared, and used in arithmetic operations. Primitive values are stored directly in memory and can be accessed quickly, which makes them more efficient than objects in terms of memory usage and performance.

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

Which two constructs characterize an object-oriented programming language?

A

Classes and objects.

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

This line declares a method called main

A

public static void main(String[] args)

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

A method is…?

A

An executable element inside a class

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

A reference variable is…?

A

A variable that stores the reference to an object in memory

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

What does compilation mean?

A

to transform a program written in a high-level programming language from source code into object code.

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

Source code must go through several steps before it becomes an executable program. Explain the two steps.

A

The first step is to pass the source code through a compiler, which translates the high-level language instructions into object code.

The final step in producing an executable program — after the compiler has produced object code — is to pass the object code through a linker. The linker combines modules and gives real values to all symbolic addresses, thereby producing machine code.

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

Java, being a platform-independent programming language, doesn’t work on the one-step compilation. Instead, it involves a two-step execution

A

The first step is through an OS-independent compiler
The second, is in a virtual machine (JVM) which is custom-built for every operating system.

24
Q

The ______ translates the high-level language instructions into object code.

A

compiler

25
Q

The _____ combines modules and gives real values to all symbolic addresses, thereby producing machine code.

A

linker

26
Q

The Java source code file is passed through the compiler, which then encodes the source code into a machine-independent encoding known as _____

A

bytecode

27
Q
  1. Which of these is NOT a component when executing a Java program in the Java Virtual Machine (JVM)? Why?

Assembler
ClassLoader
Bytecode Verifier
Just-In-Time Compiler

A

Assembler - Assembler, on the other hand, is a component of the traditional compilation process, in which source code is translated into machine code directly, rather than being compiled to bytecode for execution in the JVM

28
Q

The three components when executing a Java program in the Java virtual machine (jvm)?

A

ClassLoader is responsible for loading Java classes into memory as they are needed during program execution.

Bytecode Verifier ensures that the bytecode instructions are safe and conform to the Java language specification before they are executed.

Just-In-Time Compiler (JIT) dynamically compiles frequently used bytecode instructions into native machine code, optimizing program performance.

29
Q

What are reference types?

A

Types are defined by classes in the Java application Programming Interface (API) or by classes you create rather than by the language itself.

Reference types are created using the new keyword, which allocates memory for an object on the heap and returns a reference to it. Reference variables store the reference to the object, rather than the object itself.

Classes: Classes are templates or blueprints that define the attributes and behaviors of objects.

Interfaces: Interfaces are similar to classes, but they only define method signatures without implementations. Classes can implement interfaces to fulfill the contract defined by the interface.

Arrays: Arrays are ordered collections of elements, which can be of any type, including other reference types.

30
Q

What is the difference between a primitive and a reference variable?

A

A primitive variable stores a value, a reference variable stores the memory address of an object
Memory allocation: Primitive variables are allocated memory on the stack, whereas reference variables are allocated memory on the heap.

31
Q

What is the default type of variable used for decimals?

A

Double

32
Q

How many bit is a byte?

A

8 bit

33
Q

How many bit is a short?

A

16 bit

34
Q

How many bit is a char?

A

16 bit

35
Q

How many bit is an int?

A

32 bit

36
Q

How many bit is a long?

A

64 bit

37
Q

How many bit is a float?

A

32 bit

38
Q

How many bit is a double?

A

64 bit

39
Q

Explain what a String is

A

they are immutable, constant objects derived from the String class. To be immutable means that the state or value of the object cannot be altered once created - this is accomplished by having internal, private and final fields and not implementing any “setter” methods which would alter the state of those fields.

40
Q

When comparing Strings, the == operator will compare ____

A

Memory addresses

41
Q

What will be printed by the following block of Java code? Why?
String str1 = “my string”;
str1.concat(“ is the best!”);
System.out.println(str1);

A

“my string” because concat() method of the String class returns a new String object that represents the concatenation of the original String and the argument string. However, the original String object is not modified by the concat() method. Therefore, if the concat() method is called on a String object, like str1 in the code above, a new String object is returned but the original String object remains unchanged.

42
Q

What is debugging?

A

Debugging in computer programming is a multi-step process that involves identifying a problem, isolating the source of the problem, and then either correcting the problem or determining a way to work around it.

43
Q

In software development, the debugging process begins __________

A

when a developer locates a code error in a computer program and is able to reproduce it. Debugging is part of the software testing process and is an integral part of the entire software development lifecycle.

44
Q

Repeatedly dividing the code into halves and commenting out one half to find an error is known as the _____ method of debugging.

A

Binary search

45
Q

Each JVM thread (a path of execution) is associated with a

A

stack that’s created when the thread is created

46
Q

A new _____ is created each time a method is called.

A

Frame

47
Q

A _____ is a report of the active stack frames at a certain point in time during a thread’s execution.

A

stack trace

48
Q

In Java there are three methods to print exception information. All of them are present in the _____ class.

A

Throwable

49
Q

What is casting?

A

the process of converting a data type to another data type. This is also called type casting. Casting is necessary is some situations when we receive a data type that needs to have some actions performed on it that its original form cannot handle.

50
Q

Automatic conversions can happen in 2 instances in java. What are they?

A

Java can automatically convert some primitive types to others and do so whenever necessary.

This automatic conversion is supported when the types are compatible with range and precision.

The original data type must have a smaller size in memory (and thus is capable of holding a smaller range in values) than the target type.

The target type must also hold the same or greater precision past the decimal point, so that there is no data lost in the conversion.

Whenever you perform a mathematical operation on two values that aren’t of the same type, Java automatically converts one of them to the type of the other.

51
Q

List Arithmetic operators

A

(+, -, *, /, %)

52
Q

List Logical operators

A

(&&, ||, !)

53
Q

List Comparison operators

A

(>, <, ==, >=, <=, !=)

54
Q

List Assignment operators

A

(=, +=, -=, *=, /=, %=)

55
Q

List Increment and decrement operators

A

(++, –)