Java programming

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/63

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:44 PM on 10/5/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

64 Terms

1
New cards

Statement

A single line of Java code that performs an action

2
New cards

Expression

A combination of variables,values,and operators that produces a result

3
New cards

Assignment Statement

Stores a value in a variable using =

4
New cards

Conditional Statement

Executes code based on a true or false condition

5
New cards

Selection

A control structure that chooses between alternatives

6
New cards

if Statement

Executes code only if a condition is true

7
New cards

if-else Statement

Executes one block if true and another if false

8
New cards

else-if Ladder

Checks multiple conditions in sequence

9
New cards

switch Statement

Selects code to execute based on a variable’s value

10
New cards

Method

A reusable block of code that performs a specific task

11
New cards

Method Definition

The code that specifies what a method does

12
New cards

Method Call

The use of a method to execute its code

13
New cards

Parameter

A value passed into a method

14
New cards

Return Type

The data type a method sends back

15
New cards

void Method

A method that does not return a value

16
New cards

Loop

A structure that repeats code while a condition is met

17
New cards

while Loop

Repeats while a condition is true

18
New cards

do-while Loop

Runs once before checking the condition

19
New cards

for Loop

Repeats using initialization,condition,and update

20
New cards

Infinite Loop

A loop that never stops because the condition is always true

21
New cards

Array

A collection of elements of the same data type

22
New cards

Array Declaration

Defines an array variable

23
New cards

Array Initialization

Assigns values to an array

24
New cards

Array Index

The position of an element starting at 0

25
New cards

Array Length

The number of elements in an array

26
New cards

Traversing an Array

Accessing each element using a loop

27
New cards

Class

A blueprint for creating objects

28
New cards

Object

An instance of a class

29
New cards

Instance Variable

A variable that belongs to an object

30
New cards

Constructor

A special method that initializes objects

31
New cards

this Keyword

Refers to the current object

32
New cards

Inheritance

A mechanism where one class acquires another class’s properties

33
New cards

Superclass

The class being inherited from

34
New cards

Subclass

The class that inherits from another

35
New cards

extends Keyword

Used to inherit a class

36
New cards

Method Overriding

A subclass provides its own version of a method

37
New cards

super Keyword

Refers to the superclass

38
New cards

Encapsulation

Bundling data and methods together and restricting access

39
New cards

Access Modifier

Controls visibility of classes,methods,and variables

40
New cards

public

Accessible from anywhere

41
New cards

private

Accessible only within the class

42
New cards

protected

Accessible within the package or subclasses

43
New cards

Polymorphism

The ability for different objects to respond differently to the same method call

44
New cards
Consider the following Java code fragment.What is the index of the element with value 50?int[] arr={10,20,30,40,50};
4
45
New cards
Consider the following Java code fragment.What will be printed?int[] arr={1,2,3};System.out.println(arr[1]);
2
46
New cards
Consider the following Java code fragment.What happens?int[] arr={5,10,15};System.out.println(arr[3]);
ArrayIndexOutOfBoundsException
47
New cards
Consider the following Java code fragment.How many times does the loop execute?for(int i=0;i<5;i++){System.out.print(i);}
5
48
New cards
Consider the following Java code fragment.What is printed?for(int i=1;i<=3;i++){System.out.print(i);}
123
49
New cards
Consider the following Java code fragment.What is printed?int x=10;if(x>5){System.out.print("Yes");}else{System.out.print("No");}
Yes
50
New cards
Consider the following Java code fragment.What is printed?int x=5;if(x>10){System.out.print("A");}else{System.out.print("B");}
B
51
New cards
Consider the following Java code fragment.What is the final value of x?int x=0;while(x<4){x++;}
4
52
New cards
Consider the following Java code fragment.How many times does the loop execute?int i=0;do{i++;}while(i<3);
3
53
New cards
Consider the following Java code fragment.What is printed?String[] names={"Ann","Bob","Cat"};System.out.println(names[2]);
Cat
54
New cards
Consider the following Java code fragment.What does this code do?for(String s:names){System.out.print(s);}
Prints all elements of the array
55
New cards
Consider the following Java code fragment.What is returned?public static int add(int a,int b){return a+b;}add(2,3);
5
56
New cards
Consider the following Java code fragment.What happens if no return statement exists in a non-void method?
Compile-time error
57
New cards
Consider the following Java code fragment.What is printed?int[] nums=new int[3];System.out.println(nums[0]);
0
58
New cards
Consider the following Java code fragment.What is the array length?int[] arr={7,8,9,10};
4
59
New cards
Consider the following Java code fragment.What keyword is used to inherit a class?
extends
60
New cards
Consider the following Java code fragment.What is the purpose of this constructor?public Car(){}
Initializes a Car object
61
New cards
A while loop always executes at least once
False
62
New cards
Local variables exist only while a method is executing
True
63
New cards
Array indexes in Java start at 1
False
64
New cards
A subclass can override a method from its superclass
True