Java Fundamentals Flashcards

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
Q

Describe a decimal number system

A

A decimal number system is based on 10, it goes from 0 to 9

26
Q

Describe a hexadecimal number system

A

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
Q

Describe a java applet

A

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
Q

Describe a literal

A

A literal is fixed value that is represented in human-readable form

29
Q

Describe advantages of encapsulation

A
  1. Protects encapsulated data

2. Changes are restricted to the objects or classes

30
Q

Describe an instance variable

A

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
Q

Describe an octal number system

A

An octal is a number system that is based on 8 i.e. the numbers go from 0 to 7

32
Q

Describe auto-unboxing

A

Auto-unboxing is the process by java automatically extracts a value from a type wrapper when its value is needed

33
Q

Describe autoboxing

A

autoboxing is the process whereby java automatically encapsulates a primitive type into its equivalent wrapper whenever an object of that type is required

34
Q

Describe encapsulation

A

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
Q

Describe Inheritance

A

The process by which an object can inherit the properties of another object

36
Q

Describe Polymorphism

A

Polymorphism is a concept that allows a general interface to make use of a general class - one interface taking multiple forms

37
Q

Describe the advantage(s) of auto-unboxing

A

Auto-unboxing always creates the right value

38
Q

Describe the advantage(s) of autoboxing

A

Autoboxing always creates the proper object, ie compatible types are created

39
Q

Describe the three select statements available in java

A
  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
Q

Explain Object Oriented Programming

A

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
Q

Floating-point types can represent numbers that have _ components

A

Floating-point types can represent numbers that have fractional components

42
Q

Give an example of auto-unboxing

A

Integer intBox = 3; //autoboxing

int i = intBox; //auto-unboxing

43
Q

Give an example of autoboxing

A

Integer intBox = 3; //autoboxing

44
Q

Give an example of boxing

A

Integer boxInt = new Integer(100)

45
Q

Give an example of unboxing

A
Integer boxInt = new Integer(100) //boxing
int unboxInt = boxInt.intValue() //unboxing
46
Q

How do you call a static method from outside its class

A

classname.method()

47
Q

How do you define an array when you do not know the size of the array?

A
You use the new keyword, e.g.
int [] a;
Random rand = new Random();
a = new int [rand.nextInt()];
48
Q

How do you specify a float literal?

A

By appending an f or F in front of the literal, eg. 5.2f

49
Q

How do you specify a long literal?

A

By appending an L or l in front of the literal, eg. 5L

50
Q

How does the switch statement work

A

performs one of many different actions, depending on the value of the expression

51
Q

In Java, char is an _ 16-bit type

A

In Java, char is an unsigned 16-bit type

52
Q

Java does not support unsigned integers. What are unsigned integers?

A

Unsigned integers are integers that only support positive integers

53
Q

Java supports signed integers. What are signed integers

A

Signed integers are integers that support both positive and negative integers

54
Q

Java Virtual Machine

A

a JVM is part of the java runtime architecture that is responsible for the interpretation of the java bytecode

55
Q

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

explain main

A

main is the class from which all java applications execute

56
Q

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

what does static do

A

Static allows main to be called before an object of the class has be created

57
Q

The smallest type of an integer is called _

A

the smallest type of an integer is a byte

58
Q

True or False, the order of initialization follows the order in which the variables are defined within a class

A

True

59
Q

True or False, variables declared inside a method are initialized by java

A

False - variables declared inside a method are not initialized by java

60
Q

True or False, you cannot apply the static keyword to local variables, it only applies to fields (instance variables)

A

True