0% found this document useful (0 votes)
2 views23 pages

COS202miniNote

The document provides an overview of Java programming, including the role of garbage collectors, phases of a Java program, and features of Java. It discusses various Integrated Development Environments (IDEs) for Java, data types, operators, control statements, and includes sample code for practical applications. Additionally, it explains the use of comments, escape sequences, and provides examples of conditional statements.

Uploaded by

jinadore307
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views23 pages

COS202miniNote

The document provides an overview of Java programming, including the role of garbage collectors, phases of a Java program, and features of Java. It discusses various Integrated Development Environments (IDEs) for Java, data types, operators, control statements, and includes sample code for practical applications. Additionally, it explains the use of comments, escape sequences, and provides examples of conditional statements.

Uploaded by

jinadore307
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

What are garbage collectors in java?

The Java garbage collector runs in the background, keeping track of which objects the
application no longer needs and reclaiming memory from them

Discuss the phases of a Java program with the aid of a diagram

The first step in creating a Java program is by writing your programs in a text editor-
Integrated Development Environment (IDE). Examples of text editors you can use
are notepad, NetBeans and Eclipse, etc. This file is stored in a disk file with the
extension .java.

After creating and saving your Java program, compile the program by using the Java
Compiler. The output of this process is a file of Java bytecodes with the file
[Link]. The .class file is then interpreted by the Java interpreter that converts
the bytecodes into the machine language of the particular computer you are using.

Summary of Phases of a Java Program

Task Tool to use Output


Write the program Any text editor File with .java extension
Compile the program Java Compiler File with .class
extension
Run the program Java Interpreter (Java bytecodes)
Program Output

Outline at least four IDE used for java program


USING AN IDE
The IDE (integrated development environment) is the environment or text editor for
writing your programs. There are a number of IDE’s present, all of them are fine but
perhaps some are easier to work with than others. It depends on the Student’s level of
programming and tastes! The following is a list of some of the IDE’s available:
 BlueJ – [Link] (freeware)
 NetBeans – [Link] (freeware/open-source)
 JCreator – [Link] (freeware version available, pro version
purchase required)
 Eclipse – [Link] (freeware/open-source)
 IntelliJ IDEA – [Link] (trial/purchase required)
 JBuilder – [Link] (trial/purchase required)

Discuss briefly at least three features java


Features of Java (Java buzz words):
Simple: Learning and practicing java is easy because of resemblance with c and C++
Object Oriented Programming Language: Unlike C++, Java is purely OOP
Distributed: Java is designed for use on network; it has an extensive library which
works in agreement with TCP/IP
Secure: Java is designed for use on Internet Java enables the construction of
virus-free, tamper free systems
Robust (Strong/ Powerful): Java programs will not crash because of its exception
handling and its memory management features
Interpreted: Java programs are compiled to generate the byte code This byte code
can be downloaded and interpreted by the interpreter class file will have byte code
instructions and JVM which contains an interpreter will execute the byte code
Portable: Java does not have implementation dependent aspects and it yields or gives
same result on any machine
Architectural Neutral Language: Java byte code is not machine dependent, it can
run on any machine with any processor and with any OS
High Performance: Along with interpreter there will be JIT (Just In Time) compiler
which enhances the speed of execution
Dynamic: We can develop programs in Java which dynamically change on Internet
(eg: Applets)7

Commenting Your Programs


Briefly discuss your understanding of comments in java and give two types of
comments
Solution
Comments are inserted to document programs and improve their readability. The Java
compiler ignores comments, so they do not cause the computer to perform any action
when the program is run.
Single line comments : // Example1: [Link]
Multiple line comments: /* develop programs in Java which dynamically change on
Internet (eg: Applets)7 */

Escape Sequence
A character preceded by a backslash (\) is an escape sequence and has special
meaning to the compiler When an escape sequence is encountered in a print statement,
the compiler interprets it accordingly

Escape Sequence Description


\t Insert a tab in the text at this point
\b Insert a backspace in the text at this point
\n Insert a newline in the text at this point
\r Insert a carriage return in the text at this point
\f Insert a form feed in the text at this point
\' Insert a single quote character in the text at this point
\" Insert a double quote character in the text at this point
\\ Insert a backslash character in the text at this point

Complete Escape Sequence Description in the table below:


Escape Sequence Description
\\
\b
\n

Data Types: The classification of data item is called data type.


Java defines eight simple types of data (i)byte, (ii)short, (iii)int,(iv) long,(v) char,
(vi) float, (vii)double and (viii) boolean These can be put in four
groups:

Integer Data Types:These data types store integer numbers


Data Type Memory size Range
Byte 1 byte -128 to 127
Short 2 bytes -32768 to 32767
Int 4 bytes -2147483648 to 2147483647
Long 8 bytes -9223372036854775808 to
9223372036854775807
eg:
byte rno = 10;
long x = 150L; L means forcing JVM to allot 8bytes

Float Data Types: These data types handle floating point numbers
Data Type Memory size Range
Float 4 bytes -34e38 to 34e38
Double 8 bytes -17e308 to 17e308

eg:
float = 3142f;
double distance = 198e8;

Character Data Type: This data type represents a single character char data type in
java uses two bytes of memory also called Unicode system Unicode is a specification
to include alphabets of all international languages into the character set of java
Data Type Memory size Range
Char 2 bytes 0 to 65535
eg:
char ch = 'x';

Boolean Data Type:can handle truth values either true or false


eg:-
boolean response = true;
Outline at least four data type in Java and discuss any two of listed data type
with example each

OPERATORS
Operators: An operator is a symbol that performs an operation. An operator acts on
variables called operands
Arithmetic operators: These operators are used to perform fundamental operations
like addition, subtraction, multiplication etc

Operator Meaning Example Result


+ Addition 3+4 7
- Subtraction 5-7 -2
* Multiplication 5*5 25
/ Division (gives quotient) 14 / 7 2
% Modulus (gives remainder) 20 % 7 6
·

Assignment operator: This operator (=) is used to store some value into a variable
Write the compound assignment for the following (i) x = x + y (ii)
Simple Assignment Compound Assignment
x=x+y x += y
x=x–y x-=y
x=x*y x *= y
x = x /y x /= y

Unary operators: As the name indicates unary operator‟s act only on one operand
Operator Meaning Example Explanation
- Unary minus j = -k; k value is negated and stored into j
++ increment b++; b value will be incremented by 1(called as
post incrementation)
operator ++b; b value will be incremented by 1
(called as pre incrementation)

-- Decrement b--; b value will be decremented by 1


Operator (called as post
decrementation)
--b; b value will be decremented by 1
(called as pre decrementation)

Relational operators: These operators are used for comparison purpose


Operator Meaning Example
== Equal x == 3
!= Not equal x != 3
< Less than x<3
> Greater than x>3
<= Less than or equal to x <= 3
>= Greater than or equal to x> = 3
Logical operators: Logical operators are used to construct compound conditions
A compound condition is a combination of several simple conditions
Operator Meaning Example Explanation
&& and operator if(a>b && a>c) If a value is greater
than b and c
Systemoutprint(“yes”);
then only yes is
displayed
|| or operator if(a==1 || b==1) If either a value is 1 or b
value is 1
Systemoutprint(“yes”);
then yes is displayed
! not operator if( !(a==0) ) If a value is not equal to
zero
Systemoutprint(“yes”);
then only yes is
displayed
.
Bitwise operators: These operators act on individual bits (0 and 1) of the operands
They act only on integer data types, ie byte, short, long and int

Operator Meaning Explanation


& Bitwise AND Multiplies the individual bits of operands
| Bitwise OR Adds the individual bits of operands
<< Left shift Shifts the bits of the number towards left a
specified number of positions
>> Right shift Shifts the bits of the number towards right
a specified number of positions and also
preserves the sign bit
>>> Zero fill right shift Shifts the bits of the number
towards right a specified number of
positions and it stores 0 (Zero)
in the sign bit
~ Bitwise complement Gives the complement form of a given
number by
changing 0‟s as 1‟s and vice versa

The following table lists the bitwise operators −


Question: Assume integer variable A holds the value 60 and variable B holds the
value 13. Calculate the following bitwise operation (i) bitwise and (ii) bitwise or (iii)
bitwise XOR (iv) A << 2 (v) A >> 2

Assume integer variable A holds 60 and variable B holds 13 then −

Operator Description Example


Binary AND Operator copies a bit to the (A & B) will give 12 which is
& (bitwise and)
result if it exists in both operands. 0000 1100
Binary OR Operator copies a bit if it (A | B) will give 61 which is
| (bitwise or)
exists in either operand. 0011 1101
Binary XOR Operator copies the bit if it (A ^ B) will give 49 which is
^ (bitwise XOR)
is set in one operand but not both. 0011 0001
(~A ) will give -61 which is 1100
Binary Ones Complement Operator is
~ (bitwise compliment) 0011 in 2's complement form due
unary and has the effect of 'flipping' bits.
to a signed binary number.
Binary Left Shift Operator. The left
operands value is moved left by the A << 2 will give 240 which is
<< (left shift)
number of bits specified by the right 1111 0000
operand.
Binary Right Shift Operator. The left
operands value is moved right by the A >> 2 will give 15 which is
>> (right shift)
number of bits specified by the right 1111
operand.
Shift right zero fill operator. The left
operands value is moved right by the
A >>>2 will give 15 which is
>>> (zero fill right shift) number of bits specified by the right
0000 1111
operand and shifted values are filled up
with zeros.

Example java code to perform bitwise complement


/**
Write a description of class BitwiseOperation .

*/
public class BitwiseOperation
{
public static void main(String[] args) {

int number = 35, result;

// bitwise complement of 35
result = ~number;
[Link]("result is " +result ); // prints -36
}
}
Example 2
/**
Write a description of class BitwiseOperation .

*/

public class BitwiseOperation


{
public static void main(String[] args) {
int number = 2;

// 2 bit left shift operation


int result = number << 2;
[Link](result); // prints 8
}
}

Ternary Operator or Conditional Operator (? :): This operator is called ternary


because it acts on 3 variables
The syntax for this operator is:
Variable = Expression1? Expression2: Expression3;

First Expression1 is evaluated If it is true, then Expression2 value is stored into


variable otherwise Expression3 value is stored into the variable
eg: max = (a>b) ? a: b;

What are control statement in Java? and list the three categories
Control Statements
Control statements are the statements which alter the flow of execution and provide
better control to the programmer on the flow of execution.

In Java control statements are categorized into


i. selection control statements,
ii. iteration control statements and
iii. jump control statements
Java’s Selection Statements: Java supports two selection statements: if satelemnt ,
if else stateemnt , if else if statement and switch
These statements allow us to control the flow of program execution based on
condition

if Statement: if statement performs a task depending on whether a condition is true or


false

Syntax for if statement


if (condition) {
// code to execute if condition is true
}

Example
if (x > 0) {
[Link]("Positive number");
}

Syntax: if else
if (condition)
statement1;
else
statement2;

Example
if (x > 0) {
[Link]("Positive number");
} else {
[Link]("Non-positive number");
}

Syntax for
if else if statment
if (condition1) {
// code if condition1 is true
} else if (condition2) {
// code if condition2 is true
} else if (condition3) {
// code if condition3 is true
} else {
// code if none of the conditions are true
}

Example
if (x > 0) {
[Link]("Positive");
} else if (x < 0) {
[Link]("Negative");
} else {
[Link]("Zero");
}

Syntax for nested if


if (condition1) {
if (condition2) {
// code if both condition1 and condition2 are true
}
}
Example
Write a java statement to display posive even number
if (x > 0) {
if (x % 2 == 0) {
[Link]("Positive even number");
}
}

Statement Use Case


if Single condition
if-else Two possible outcomes
if-else-if Multiple conditions
nested if Hierarchical decisions
switch Multiple discrete values
Question write a java program to calculate grade using if esle if grade are 0-39 is F,
40-44 is E, 45-49 is D, 50-59 is C, 60- 69 is B and 70 and above is A

import [Link];

public class GradeCalculator {


public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);

// Input score
[Link]("Enter your score: ");
int score = [Link]();

// Determine grade using if-else-if


if (score >= 0 && score <= 39) {
[Link]("Grade: F");
} else if (score >= 40 && score <= 44) {
[Link]("Grade: E");
} else if (score >= 45 && score <= 49) {
[Link]("Grade: D");
} else if (score >= 50 && score <= 59) {
[Link]("Grade: C");
} else if (score >= 60 && score <= 69) {
[Link]("Grade: B");
} else if (score >= 70) {
[Link]("Grade: A");
} else {
[Link]("Invalid score! Please enter a value between 0 and
100.");
}

[Link]();
}
}

Program 1: Write a program to find biggest of three numbers


//Biggest of three numbers
class BiggestNo
{public static void main(String args[])
{ int a=5,b=7,c=6;
if ( a > b && a>c)
Systemoutprintln ("a is big");
else if ( b > c)
Systemoutprintln ("b is big");
else
Systemoutprintln ("c is big");
}
}
// program to find the biggest number using scanner facility

import [Link];

public class BiggestOfThree {


public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);

// Input three numbers


[Link]("Enter first number: ");
int num1 = [Link]();

[Link]("Enter second number: ");


int num2 = [Link]();

[Link]("Enter third number: ");


int num3 = [Link]();

int biggest;

// Compare using if statements


if (num1 >= num2 && num1 >= num3) {
biggest = num1;
} else if (num2 >= num1 && num2 >= num3) {
biggest = num2;
} else {
biggest = num3;
}

[Link]("The biggest number is: " + biggest);

[Link]();
}
}

Question Write a Java program named VotingEligibility that determines whether a


person is eligible to vote. The program should prompt the user to input their
citizenship status (yes/no) and their age. Using conditional statements (if/else), the
program should check if the user is both a citizen and older than 18 years. If both
conditions are satisfied, the program should display a message indicating that the user
is eligible to vote; otherwise, it should display that the user is not eligible to vote.

// java program to find voting eligibility


import [Link];

public class VotingEligibility {


public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);

// Input citizenship status


[Link]("Are you a citizen? (yes/no): ");
String citizenship = [Link]().trim().toLowerCase();

// Input age
[Link]("Enter your age: ");
int age = [Link]();

// Check eligibility
if ([Link]("yes") && age > 18) {
[Link]("You are eligible to vote.");
} else {
[Link]("You are not eligible to vote.");
}

[Link]();
}
}

Output:
Switch Statement: When there are several options and we have to choose only one
option from the available ones, we can use switch statement

Syntax:
switch (expression)
{ case value1: //statement sequence
break;
case value2: //statement sequence
break;
……………
case valueN: //statement sequence
break;
default: //default statement sequence
}

switch (day) {
case 1: [Link]("Monday"); break;
case 2: [Link]("Tuesday"); break;
default: [Link]("Other day");
}

Question Write a Java program that utilizes the switch statement to determine and
display the name of a month in a calendar year. Specifically, ensure that the program
correctly outputs the month of March when the corresponding case is selected.

// java program to display the name of a month in a calendar year


public class MonthSwitch {
public static void main(String[] args) {
int month = 3; // March is the 3rd month

switch(month) {
case 1:
[Link]("January");
break;
case 2:
[Link]("February");
break;
case 3:
[Link]("March");
break;
case 4:
[Link]("April");
break;
case 5:
[Link]("May");
break;
case 6:
[Link]("June");
break;
case 7:
[Link]("July");
break;
case 8:
[Link]("August");
break;
case 9:
[Link]("September");
break;
case 10:
[Link]("October");
break;
case 11:
[Link]("November");
break;
case 12:
[Link]("December");
break;
default:
[Link]("Invalid month number");
}
}
}
Question: Write a Java program named RechargeCardApp that simulates the purchase
of recharge cards using a switch statement. The program should prompt the user to
enter an amount (e.g., 100, 200, or 300). Based on the input, the program should
display a message confirming the card value. If the user enters an amount outside the
available options, the program should display an error message indicating that no card
is available for the chosen option

// Java program to sell recharge card


import [Link];

public class RechargeCardApp


{
public static void main () {
Scanner sc = new Scanner ([Link]);
[Link] (" Youramount");
int YouramountIn = [Link]();
switch (YouramountIn)
{
case 100: [Link] ("take your card of N"+YouramountIn); break;
case 200: [Link] ("take your card of N"+YouramountIn); break;
case 300: [Link] ("take your card of N"+YouramountIn); break;
default: [Link] ("No card available for this option"); break;
}
[Link]();

}
}

Java’s Iteration Statements: Java‟s iteration statements are for, while and do-while
These statements are used to repeat same set of instructions specified number of times
called loops.
A loop repeatedly executes the same set of instructions until a termination condition
is met

while Loop: while loop repeats a group of statements as long as condition is true
Once the condition is false, the loop is terminated.
In while loop, the condition is tested first;
if it is true, then only the statements are executed while loop is called as entry control
loop

Syntax:while (condition)
{
statements;
}

Program 3: Write a program to generate numbers from 1 to 20


//Program to generate numbers from 1 to 20
class Natural
{public static void main(String args[])
{int i=1;
while (i <= 20)
{Systemoutprint (i + “\t”);
i++;
}
}
}

do…while Loop: do…while loop repeats a group of statements as long as condition


is
true .
In do while loop, the statements are executed first and then the condition is tested
do…while loop is also called as exit control loop

Syntax: do
{
statements;
} while (condition);

Program 4: Write a program to generate numbers from 1 to 20


//Program to generate numbers from 1 to 20
class Natural
{public static void main(String args[])
{int i=1; do
{Systemoutprint (i + “\t”); i++;
} while (i <= 20);
}
}
Ex
// Program to generate numbers from 1 to 20 using do-while loop
class NaturalDoWhile {
public static void main(String[] args) {
int i = 1; // starting point

do {
[Link](i + "\t"); // print number with tab space
i++; // increase by 1
} while (i <= 20); // condition checked after each loop
}
}

for Loop: The for loop is also same as do…while or while loop, but it is more
compact syntactically The for loop executes a group of statements as long as a
condition is true
Syntax
for(initialization; condition; update) {
// code to be executed
}

Or
Syntax: for (expression1; expression2; expression3)
{ statements;
}

Here, expression1 is used to initialize the variables, expression2 is used for condition
checking and expression3 is used for increment or decrement variable value
Program 5: Write a program to generate numbers from 1 to 20
//Program to generate numbers from 1 to 20
class NaturalNumbers
{
public static void main(String args[])
{ int i;
for (i=1; i<=20; i++)
Systemoutprint (i + “\t”);
}
}
Introduction to OOPs
Languages like Pascal, C, FORTRAN, and COBOL are called procedure oriented
programming languages Since in these languages, a programmer uses procedures or
functions to perform a task When the programmer wants to write a program, he will
first divide the task into separate sub tasks, each of which is expressed as functions/
procedures This approach is called procedure oriented approach.

The languages like C++ and Java use classes and object in their programs and are
called Object Oriented Programming languages The main task is divided into several
modules and these are represented as classes Each class can perform some tasks for
which several methods are written in a class This approach is called Object Oriented
approach

Features of OOP:
Class: In object-oriented programming, a class is a programming language construct
that is used as a blueprint to create objects This blueprint includes attributes and
methods that the created objects all share Usually, a class represents a person, place,
or thing - it is an abstraction of a concept within a computer program.

General form of a class:


class class_name
eg: class Student

Object: An Object is a real time entity An object is an instance of a class.


Instance means physically happening
An object will have some properties and it can perform some actions. Object contains
variables and methods.
eg: Student s; // s is reference variable
s = new Student (); // allocate an object to reference variable s

Encapsulation: Wrapping up of data (variables) and methods into single unit is called
Encapsulation. Class is an example for encapsulation
Encapsulation can be described as a protective barrier that prevents the code and data
being randomly accessed by other code defined outside the class
Encapsulation is the technique of making the fields in a class private and providing
access to the fields via methods If a field is declared private, it cannot be accessed by
anyone outside the class
eg: class Student
{
private int rollNo;
private String name;
//methods -- actions
void display ()
{
Systemoutprintln ("Student Roll Number is: " + rollNo);
Systemoutprintln ("Student Name is: " + name);
}
}
Abstraction: Providing the essential features without its inner details is called
abstraction
(or) hiding internal implementation is called Abstraction

Abstraction provides security

A class contains lot of data and the user does not need the entire data The advantage
of abstraction is that every user will get his own view of the data according to his
requirements and will not get confused with unnecessary data

For example A bank clerk should see the customer details like account number,
name and balance amount in the account He should not be entitled to see the sensitive
data like the staff salaries, profit or loss of the bank etc So such data can be abstracted
from the clerks view

eg: class Bank


{ private int accno;
private String name;
private float balance;
private float profit;
private float loan;
void display_to_clerk ()
{
[Link] ("Accno = " + accno);
[Link] ("Name = " + name);
[Link] ("Balance = " + balance);
}
}

Inheritance: Acquiring the properties from one class to another class is called
inheritance
(or) producing new class from already existing class is called inheritance

Reusability of code is main advantage of inheritance In Java inheritance is achieved


by using extends keyword
The properties with access specifier private cannot be inherited

eg: class Parent


{
String parentName;
String familyName;
}
class Child extends Parent
{
String childName;
int childAge;
void printMyName()
{
[Link] (“My name is“+childName+” ”+familyName);
}
}
In the above example, the child has inherited its family name from the parent class
just by inheriting the class

Polymorphism: The word polymorphism came from two Greek words „poly‟ means
„many‟ and „morphos‟ means „forms‟ Thus, polymorphism represents the ability to
assume several different forms
The ability to define more than one function with the same name is called
Polymorphism

eg:
int add (int a, int b)
float add (float a, int b)
float add (int a , float b)
void add (float a)
int add (int a)
1) Which keyword is used to define a class in Java? A. define B. class C. struct D.
object ✅ Answer: B. class
2) Which of these is not a primitive data type in Java? A. int B. float C. String D.
char ✅ Answer: C. String
3) Which symbol is used for single-line comments in Java? A. // B. /* C. # D.
<!-- ✅ Answer: A. //
4) Which method is the entry point of a Java program? A. start() B. run() C.
main() D. init() ✅ Answer: C. main()
5) Which operator is used for equality comparison in Java? A. = B. == C. equals
D. != ✅ Answer: B. ==
6) Which loop executes at least once, even if the condition is false? A. for B.
while C. do-while D. foreach ✅ Answer: C. do-while
7) Which package is automatically imported in every Java program? A.
[Link] B. [Link] C. [Link] D. [Link] ✅ Answer: B. [Link]
8) Which keyword is used to inherit a class in Java? A. implements B. extends C.
inherits D. super ✅ Answer: B. extends
9) Which keyword is used to create an object in Java? A. create B. new C. object
D. alloc ✅ Answer: B. new
10) . Which statement is used to choose between two alternatives in Java? A.
switch B. if-else C. for D. while ✅ Answer: B. if-else
11) What happens if you forget the break in a switch case? A. Compilation error
B. Program stops C. Fall-through to the next case D. Skips to default ✅ Answer:
C. Fall-through to the next case
12) Which of these can be used in a switch expression in Java? A. int B. String C.
enum D. All of the above ✅ Answer: D. All of the above
13) Which statement is used for hierarchical decision-making? A. nested if B.
switch C. for D. do-while ✅ Answer: A. nested if
14) Which loop is best when the number of iterations is known? A. while B.
do-while C. for D. switch ✅ Answer: C. for
15) Which loop checks the condition before executing the body? A. for B. while C.
do-while D. foreach ✅ Answer: B. while
16) Which loop guarantees at least one execution? A. for B. while C. do-while D.
switch ✅ Answer: C. do-while
17) What keyword is used to exit a loop immediately? A. continue B. break C. exit
D. stop ✅ Answer: B. break
18) What keyword skips the current iteration and continues with the next? A.
break B. continue C. skip D. next ✅ Answer: B. continue
19) What is the default value of an int array element in Java? A. 1 B. 0 C. null D.
undefined ✅ Answer: B. 0
20) How do you declare a one-dimensional array of integers? A. int arr[]; B. int[]
arr; C. int arr[] = new int[10]; D. All of the above ✅ Answer: D. All of the
above
21) What is the index of the first element in an array? A. 0 B. 1 C. -1 D. Depends
on declaration ✅ Answer: A. 0
22) Which loop is commonly used to traverse arrays? A. while B. for C. do-while
D. switch ✅ Answer: B. for
23) What happens if you access an array index out of bounds? A. Compilation
error B. Runtime error (ArrayIndexOutOfBoundsException) C. Returns null D.
Ignores the access ✅ Answer: B. Runtime error
(ArrayIndexOutOfBoundsException)
Instructions:

Attempt all questions in Section A – 15 marks

Attempt all questions in Section B – 25 marks

Attempt question one any other two questions in Section C – 30 marks

You might also like