cmpt 270 conceptual questions

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/31

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

32 Terms

1
New cards

what is the difference between method overloading and method overriding in Java?

one means having the same method name but different parameters, while the other means a subclass changes a method that it inherits from its superclass

2
New cards

what is the purpose of the final keyword in Java?

means that a variable’s value, a method’s behaviour, and a class’ inheritance cannot be changed

3
New cards

what is the difference between a checked exception and an unchecked exception

one must be caught with try-catch or declared in the method, but the other happens during the program and don’t have to be handled explicitly

4
New cards

what is the difference between a constructor and a method in Java?

one initializes a new object, while the other performs actions on an object

5
New cards

what does the this keyword do in a constructor or method?

refers to the current instance of the class

6
New cards

what is the purpose of the super keyword in java?

refers to the superclass and is used to call parent class methods or constructors

7
New cards

explain the difference between == and equals() in Java

one checks if two objects are the exact same thing in memory, while the other checks if their contents or values are the same

8
New cards

what is the difference between a static method and a non-static method

one belongs to the class while the other belongs to an instance of the class

9
New cards

what is a final variable, and how is it different from a regular variable?

one cannot be changed once assigned, whereas a the other one can

10
New cards

how does the try-catch block work in exception handling?

one contains code that might throw an exception, and the other handles the exception if it occurs

11
New cards

what is the purpose of throw and throws keywords in Java exceptions?

one is used to cause an exception right away, while the other tells that a method might cause an exception

12
New cards

what is the difference between String and StringBuilder in Java?

one is immutable while the other is not

13
New cards

what is polymorphism and how is it used in Java?

it lets different kinds of objects be used like they are the same type, usually by replacing methods with new versions

14
New cards

what is an abstract class in Java?

is a class you can’t make objects from, but other classes can inherit from it

15
New cards

what is the difference between an interface and an abstract class in Java?

one is a list of method names without code that any class can use, and the other can have methods with or without code and other classes can extend it

16
New cards

what is a constructor overloading in Java?

occurs when multiple constructors with different parameters are defined in a class

17
New cards

what does instanceof operator do in Java?

checks if an object is of a certain type, it verifies the object’s class when the program is being ran

18
New cards

what is the purpose of the private access modifier in Java?

restricts access to a field or method to within the same class only

19
New cards

what is the null keyword in Java?

represents the absence of a value or reference for a variable

20
New cards

what is the purpose of the continue statement in Java?

skips the current iteration of a loop and moves to the next iteration

21
New cards

what is the difference between ArrayList and LinkedList?

one stores items in a growable array and lets you quickly get any item, while the other stores items in a chain and lets you add or remove items faster

22
New cards

what does the default keyword do in an interface?

lets a method in an interface have a default code that classes can use or override

23
New cards

what is method chaining?

lets you call methods one after another on the same object in one line, because each method returns the object itself

24
New cards

what is the difference between ArrayList and HashSet?

one lets you use store methods in an ordered list, because it keeps insertion order, while the other stores unique elements in no order because it does not allow duplicates

25
New cards

what is the purpose of the static keyword?

lets you use methods or variables without creating an object, because it belongs to the class itself

26
New cards

what is the difference between a method signature and a method declaration?

method signature includes the name and parameters, because it identifies the method while the method declaration includes the return type an access modifiers, because it defines the method

27
New cards

what is the purpose of the default constructor?

creates an object without setting any values because it is automatically provided if no constructor is given

28
New cards

what is the difference between Thread.sleep() and wait()?

one pauses the thread for a certain time, while the other pauses it until another is told to continue

29
New cards

what does super() do in a constructor?

calls the parent class constructor, because it ensures the parent class is properly set up

30
New cards

what is the purpose of the final keyword in method parameters?

lets you make sure a parameter’s value cannot be changed, prevents reassignment

31
New cards

what does the this keyword do in a constructor?

refers to the current object, because it helps distinguish instance variables from parameters

32
New cards

what is a hashcode?

uniquely identifies objects because it helps quickly locate and compare objects in hash-based collections