Java Fundamentals Flashcards

(60 cards)

1
Q

Type float has _ bits and double type has _ bits

A

Type float has 32 bits and double type has 64 bits

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

What does a cast do

A

Performs an explicit conversion between incompatible data types

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

What does it mean java is a strongly typed language

A

it means that the compiler checks all operations for type errors, eg. variables have to adhere to their defined data types

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

What does static do?

A

Static allows a member of a class to be used independently of any object of that class

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

What is a bytecode?

A

A set of instructions designed to be interpreted by a java virtual machine. Bytecode results from java source code compilation by the java compiler

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

What is a default constructor

A

A default constructor is a constructor that takes no arguments

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

What is boxing

A

Boxing is the process of encapsulating a value within an object

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

What is the function of a constructor?

A

A constructor initializes an object immediately upon creation:

Books myBook = new Books() //object myBook is initialized by the Books constructor

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

what is this keyword used for

A

the this keyword is used in a non-static method to refer to the object that invoked the method

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

What is unboxing

A

Unboxing is the process of extracting a value from a type wrapper

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

Why is java considered portable

A

Its considered portable because of the java bytecode that can run on a jvm, which in turn runs on different platforms

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

Why is java considered secure

A

Java is considered secure because java programs are constrained within the jvm, preventing them from generating harmful side effects that run outside of the jvm

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

What are the 8 primitive java data types

A

boolean, short, int, float, double, char, byte,long

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

What are the restrictions faced by methods declared as static?

A
  1. They can only call other static methods
  2. They must access only static data
  3. They cannot refer to this or super
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are wrappers

A

Wrappers are classes that encapsulate a primitive type within an object

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

What is a bytecode?

A

A set of instructions designed to be interpreted by a java virtual machine. Bytecode results from java source code compilation by the java compiler

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

Why is java considered portable

A

Its considered portable because of the java bytecode that can run on a jvm, which in turn runs on different platforms

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

A string instance variable has a default initial value of _

A

A string instance variable has a default initial value of NULL

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

An integer instance variable has a default initial value of _

A

An integer instance variable has a default initial value of 0

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

By default, floating-point literals are of type _

A

By default, floating-point literals are of type double

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

By default, integer literals are of type _

A

By default, integer literals are of type int

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

Characters in java are indices into the _ character set, and they are _ bit values that can be converted into_ and manipulated with _ operators, such as _ and _ operators

A

Characters in java are indices into the Unicode character set, and they are 16-bit values that can be converted into integers and manipulated integer operators, such as the addition and subtraction operators

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

Describe \

A

Backslash

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

Describe \b

A

Backspace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe a decimal number system
A decimal number system is based on 10, it goes from 0 to 9
26
Describe a hexadecimal number system
A hexadecimal is a number system that is based on 16. i.e. it goes from 0 to 9 and then from A to F, with the letters representing 10, 11, 12, 13, 14, 15
27
Describe a java applet
A java applet is a small dynamic java application that runs on the web, performing tasks such as interactive animation, calculations and other simple tasks without having to send a user request back to the server
28
Describe a literal
A literal is fixed value that is represented in human-readable form
29
Describe advantages of encapsulation
1. Protects encapsulated data | 2. Changes are restricted to the objects or classes
30
Describe an instance variable
A variable within a class defined outside of a method, which is available to any instance of the class to which it (instance variable) belongs to
31
Describe an octal number system
An octal is a number system that is based on 8 i.e. the numbers go from 0 to 7
32
Describe auto-unboxing
Auto-unboxing is the process by java automatically extracts a value from a type wrapper when its value is needed
33
Describe autoboxing
autoboxing is the process whereby java automatically encapsulates a primitive type into its equivalent wrapper whenever an object of that type is required
34
Describe encapsulation
In its simplest form, encapsulation is information hiding. It is a concept whereby data and the code that works on the data are combined to form an object, and are hidden from external parts
35
Describe Inheritance
The process by which an object can inherit the properties of another object
36
Describe Polymorphism
Polymorphism is a concept that allows a general interface to make use of a general class - one interface taking multiple forms
37
Describe the advantage(s) of auto-unboxing
Auto-unboxing always creates the right value
38
Describe the advantage(s) of autoboxing
Autoboxing always creates the proper object, ie compatible types are created
39
Describe the three select statements available in java
1. if - single select statement, selects or ignores a single action 2. if...else - double select statement, selects between two actions 3. case - multiple select statement, selects among many different actions
40
Explain Object Oriented Programming
Object Oriented Programming is a programming style that represents ideas as objects that contain data fields(attributes that describe the object) as well as procedures(methods) that operate on the objects. Example a human is an object, whose attribute is age, and has an associated procedure, speak, that the human can do.
41
Floating-point types can represent numbers that have _ components
Floating-point types can represent numbers that have fractional components
42
Give an example of auto-unboxing
Integer intBox = 3; //autoboxing | int i = intBox; //auto-unboxing
43
Give an example of autoboxing
Integer intBox = 3; //autoboxing
44
Give an example of boxing
Integer boxInt = new Integer(100)
45
Give an example of unboxing
``` Integer boxInt = new Integer(100) //boxing int unboxInt = boxInt.intValue() //unboxing ```
46
How do you call a static method from outside its class
classname.method()
47
How do you define an array when you do not know the size of the array?
``` You use the new keyword, e.g. int [] a; Random rand = new Random(); a = new int [rand.nextInt()]; ```
48
How do you specify a float literal?
By appending an f or F in front of the literal, eg. 5.2f
49
How do you specify a long literal?
By appending an L or l in front of the literal, eg. 5L
50
How does the switch statement work
performs one of many different actions, depending on the value of the expression
51
In Java, char is an _ 16-bit type
In Java, char is an unsigned 16-bit type
52
Java does not support unsigned integers. What are unsigned integers?
Unsigned integers are integers that only support positive integers
53
Java supports signed integers. What are signed integers
Signed integers are integers that support both positive and negative integers
54
Java Virtual Machine
a JVM is part of the java runtime architecture that is responsible for the interpretation of the java bytecode
55
public static void main(String args[]){} | explain main
main is the class from which all java applications execute
56
public static void main(String args[]){} what does static do
Static allows main to be called before an object of the class has be created
57
The smallest type of an integer is called _
the smallest type of an integer is a byte
58
True or False, the order of initialization follows the order in which the variables are defined within a class
True
59
True or False, variables declared inside a method are initialized by java
False - variables declared inside a method are not initialized by java
60
True or False, you cannot apply the static keyword to local variables, it only applies to fields (instance variables)
True