MOOC Part 7 Flashcards

1
Q

What are the key differences between POP and OPP?

A
  • OOP divides program into object whereas POP divides program into functions
  • POP follows top down approach
  • OOP has access specifiers such as public and private whereas POP does not, there OOP has data hiding making it more secure
  • OOP provides an efficient way to add data and functions where POP is harder
  • method overloading is possible in OOP
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between static and non-static methods?

A

Non-static methods are instance methods, so it requires an object of its class to be created before it can be called, instance methods can access static variables and static methods directly. Static methods can be invoked by class reference whereas instance methods can only be invoked by object reference.

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

What’s the simplest way to print a Java array?

A

Arrays.toString(array)

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

What’s the simplest way to sort arrays in their natural order?

A
Use the class method sort of the Arrays class. 
Arrays.sort(array)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Main difference between array and ArrayList?

A
In java, array is a functionality whereas ArrayList is a class of the java Collections fromwork. 
Array is static in size, ArrayList is dynamic in size. 
Array is faster as it has set size. ArrayList is slower as it is backed by Array, and so its resizing operation slows down its performance. Array is multi-dimensional whereas ArrayLIst is single dimensional.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly