[M1] More Java and Git

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/48

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.

49 Terms

1
New cards

class

defines a new class

2
New cards

extends

used for inheritance

3
New cards

implements

used when a class implements an interface

4
New cards

new

creates an object

5
New cards

this

refers to the current object

6
New cards

super

refers to the superclass

7
New cards

throw

manually throws an exception

8
New cards

throws

declares that a method may throw exceptions

9
New cards

static

belongs to the class, not the object

10
New cards

final

value cannot be changed / class cannot be extended / method cannot be overridden

11
New cards

public / private / protected

access modifiers

12
New cards

return

sends a value back

13
New cards

abstract

marks abstract class/method

14
New cards

interface

declares an interface

15
New cards

import

imports another package or class

16
New cards

How does method overloading work in Java?

Overloading = same method name, different parameters (different type or count).
Resolved at compile time

17
New cards

How does method overriding work in Java?

Overriding = same method name + same parameters in a subclass.
Requires inheritance.
Uses runtime dynamic dispatch.

18
New cards

What is variable shadowing?

Shadowing happens when a local variable or parameter has the same name as a field, hiding the field.
Use this.x to refer to the field.

19
New cards

How does inheritance work in Java?

A subclass extends a superclass, meaning it:

  • gains its fields and methods

  • can override methods

  • can call super() to use parent constructors

  • supports code reuse and polymorphism

20
New cards

What is the difference between an abstract class and an interface?

  • Abstract Class:

    • Can have fields, concrete methods, and abstract methods

    • A class can extend only one abstract class

  • Interface:

    • Contains abstract methods (and default/static methods)

    • No instance fields

    • A class can implement many interfaces

21
New cards

When would you use an abstract class?

Use an abstract class when:

  • Objects share state (fields)

  • You need some shared code + some abstract methods

  • You want to enforce “is-a” hierarchy with shared functionality

22
New cards

When would you use an interface?

Use an interface when:

  • You only need to define capabilities / behaviors

  • Multiple unrelated classes should share the same behavior

  • You want multiple inheritance of type

23
New cards

JFrame

main window

24
New cards

JPanel

container

25
New cards

JButton

clickable button

26
New cards

JLabel

text label

27
New cards

JTextField

text input box

28
New cards

JOptionPane

popup alert/message input

29
New cards

Class name (uml)

class declaration

30
New cards

+ public / - private / # protected symbols (uml)

access modifiers

31
New cards

Fields (with type) (uml)

instance variables

32
New cards

Methods (with return types) (uml)

methods

33
New cards

Italic method/class names (uml)

abstract

34
New cards

Arrow with hollow triangle (uml)

inheritance (extends)

35
New cards

Dotted arrow (uml)

interface (implements)

36
New cards

Diamond (uml)

composition/aggregation depending on fullness

37
New cards

Class declaration (convert into uml)

class box

38
New cards

Fields (convert into uml)

list under "attributes"

39
New cards

Methods (convert into uml)

list under "operations"

40
New cards

Access modifiers (convert into uml)

+ (public), - (private), # (protected)

41
New cards

Abstract methods (convert into uml)

italic

42
New cards

Inheritance (convert into uml)

arrow to parent

43
New cards

Interfaces (convert into uml)

dotted arrow

44
New cards

git branch branchName

create a branch

45
New cards

git checkout branchName

switch to branch

46
New cards

git merge branchName

merge into current branch

47
New cards

git branches

Used to work on new features without touching main

48
New cards

What is a pull request (PR) and how do you create one?

A pull request is a request to merge changes from your branch into the main branch.

49
New cards

Steps for pull request

  • Create a new branch

  • Commit your changes

  • Push the branch: git push -u origin branchName

  • Open GitHub → click New Pull Request

  • Compare your branch → main

  • Add description

  • Submit PR

  • Reviewer approves and merges