Misc Flashcards

1
Q

what are 4 fundamental data types in java

A

int, float, character, boolean;

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

size and range of byte in java

A

1 byte and +127 to -128

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

size and range of short in java

A

2 byte and +32767 to -32768

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

size and range of int in java

A

4 byte and +x to -(x+1)

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

size and range of long in java

A

8 byte and +y to -(y+1)

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

size of float in java

A

4 bytes

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

size of double in java

A

8 bytes

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

The letter ‘f’ must follow these type of constants

A

float type(float and double)

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

default initial value of int

A

zero(0)

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

default initial value of float

A

zero(0.0)

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

default initial value of character

A

NA

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

default initial value of boolean

A

false

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

Two types of programming languages are:

___ oriented and ___ oriented

A

Procedural and Object

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

Difference between class and objects

A
Class exists logically; it has no space allocated in memory to it; is loaded only once in memory while execution; resides in disk as 
object is allocated space when it is created; based on its parent class definition; reside in main memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Data members of a class are also known as

A

properties/fields/attributes

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

methods of a class are also known as

A

behaviors/accessories

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

File name should be the same as the ___ name

A

Class name; although this is convention and not a rule

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

Command to execute a java program

A

java ClassName; make sure that ClassName.class exists so that ClassLoader can put it into main memory.

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

4 ways to input data to Java program

A

Keyboard; command prompt; file reading; xml file

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

Autoboxing/Unboxing is done by ____

A

Java Compiler

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

What are default packages and they are imported by whom?

A

packages that need not be explicitly imported in java programs;
put internally by java compiler

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

System class belongs to this package

A

java.lang

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

Use of this keyword

A

differentiate between members of class and formal parameters of same name.

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

obj1.method_name(obj2);

obj1 and obj2 are

A

source/invoking object, and destination/target object respectively.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
5 types of inheritance are
single/multilevel/multiple/hierarchical/hybrid
26
If we don't want our class to be inherited, we must define it as ___ class
final class
27
If we don't want to give some methods/members of base class to derived class
the must be declared private
28
Java does not allow ___ classes however ___ ___ classes are allowed
private, and Inner Private
29
scope of base class object is ___
can access base class objects but not derived class objects.
30
types of relationships between classes in java
is_a, has_a, and uses_a
31
is_a relationship uses ___ keyword
extends
32
is_a relationship follows ___ memory management
logical
33
define has_a relationship
an object of one class is used as data member of another class
34
define uses_a relationship
a method in the class uses an object of another class.
35
All java classes have a default ___ relationship because ___ class is base of all classes
is_a, Java.Lang.Object
36
example of has_a relationship
System.out which contains out, out is an object of the PrintStream class.
37
super keyword is used for
accessing same name methods/members of the base class in the derived class.
38
When derived class constructor is called the constructors of base class are called ____ but are executed ___
bottom-to-top; top-to-bottom
39
use of this() constructor
calls current class default constructor from current class parameterized constructor
40
use of this(....) constructor
used to call current class constructor from other constructors
41
when using this() and this(....) we must avoid having ___
cyclic calling of constructors.
42
two ways to implement polymorphism with methods in java
method overloading; method overriding
43
two types/principles of polymorphism
static/compile time polymorphism; | dynamic/run time polymorphism
44
we can't create an object of an abstract class directly, but we can do so by ___
creating an implementation/derived class.
45
abstract method cannot be ___, ___ & ___
private, final, static
46
what are the two types of packages in java
1) pre-defined/built-in 2) user-defined
47
This package is also called the default package in java
java.lang.*; it is imported by default in all classes.
48
java.lang.* has these following five basic facilities
1) command line arguments 2) data conversions 3) garbage collection 4) developing thread based apps 5) developing exception based apps
49
private modifier is also known as ___
native access modifier
50
default modifier is also known as ___
package access modifier
51
protected access modifier is also known as ___
inherited access modifier
52
public access modifier is also known as ___
universal access modifier
53
is default a keyword in java?
no
54
what are the three types of errors we get in all programming languages?
1) compile time errors 2) logical errors 3) run time errors
55
what is a logical error?
logical errors are errors that produce wrong result according to business logic,
56
how is a logical error different from a runtime error?
runtime errors don't produce any wrong output, they simply terminate the program. they are a result of invalid operation/input.
57
what are the two types of exceptions?
1) pre-defined/built-in exceptions | 2) user/programmer/custom-defined exceptions
58
pre-defined exceptions are of two types. what are they?
synchronous and asynchronous types
59
synchronous exceptions are of two types. what are they?
checked and un-checked
60
5 keywords often used when handling exceptions
1. try 2. catch 3. finally 4. throw 5. throws
61
nested try blocks are permitted in java. true/false
true
62
one can write try catch blocks in finally. true/false
true
63
out and err are objects of which class?
PrintStreamClass, which are used in System class
64
3 ways to print error messages in exceptions
1. print object of Exception/Throwable class. 2. use printStackTrace() 3. use getMessage() in Exception object
65
2 ways of creating a thread class
using: 1. java.lang.Thread class 2. java.lang.Runnable interface
66
use, and prototype of setName, and getName in Thread class
used to set user-friendly names for threads public final void setName(String); public final String getName();
67
use, and prototype of setPriority, and getPriority in Thread class
public final void setPriority(int); | public final int getPriority();
68
use, and prototype of isAlive()
true if thread is in execution; false otherwise(halted state, or new state) public boolean isAlive()
69
use of public void run()
in this method we write the java code that has to be executed by the thread. it is a null body method that we override from the Thread class.
70
use of public final void start()
1. moves thread from READY to NEW state 2. provides multithreading services(concurrency, synchronization, and ITC) 3. automatically calls run() which contains the logic of thread
71
use of suspend()
puts a thread into WAITING state. suspends its execution. it can be resumed from here.
72
use of resume()
move a thread from WAITING state to READY state | thread continues execution from where it had started.
73
use of stop()
move a thread into the HALTED state | thread stops execution completely, and cannot be resumed from there.
74
use of public final ThreadGroup getThreadGroup()
get the thread group name of foreground thread
75
use of 'public static final Thread currentThread()'
it is a factory method | returns all the thread that are currently running
76
use of 'public static final void sleep(long)'
makes a thread pause for certain number of milliseconds
77
ThreadGroupName always resides in this method
main()