wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Revision 1

Total questions: 98

Worksheet time: 49mins

Name
Class
Date
1.

What is the type of error, if any, when two methods have the same method signature?

a)

Runtime error

b)

Logical error

c)

Syntax error

d)

No error

2.

The advantage/s of user-defined methods are/is:

(i) Reusability

(ii) Complexity

(iii) Modularity

a)

Only (i)

b)

(ii) and (iii)

c)

Only (iiii)

d)

(i) and (iii)

3.

Which of the following is a valid method prototype?

a)

public int perform (int a;int b)

b)

public perform (int a, int b)

c)

public int perform (int a, int b)

d)

public perform int (int a, int b)

4.

Which of the following is the CORRECT statement to invoke the method with the prototype int display(int a, char ch)?

a)

int m = display('A', 45);

b)

int m = display( );

c)

int m = display(A,45);

d)

int m = display(45, 'A');

5.

Which of the following is the CORRECT java statement to convert the word RESPECT to lowercase?

a)

"RESPECT".tolowercase( );

b)

"RESPECT".toLowerCase( );

c)

toLowerCase("RESPECT");

d)

String.toLowerCase("RESPECT");

6.

Which of the following are Wrapper classes?

a)

(i) and (iv)

b)

(ii) and (iv)

c)

(i) and (iii)

d)

(ii) and (iii)

7.

Conversion of a wrapper class to its corresponding primitive type is known as :

a)

unboxing

b)

autoboxing

c)

type casting

d)

parsing

8.

The String method, which results only in a positive integer, is :

a)

indexOf

b)

lastIndexOf

c)

compareTo

d)

length

9.

The method to convert a String to double is:

a)

String. toDouble()

b)

Double. Parsedouble()

c)

Double. parseDouble(String)

d)

Double. parseDouble( )

10.

The java statement System. out. println(x[x. length]) results in:

a)

logical error

b)

syntax error

c)

run time error

d)

no error

11.

Which of the following is a valid array declaration statement to store the Gender of 80 employees

[ ‘M’-male, ‘F’-female, ‘T’-transgender ]?

a)

char gender = new char[80];

b)

char gender[] = new char[80];

c)

char gender[80];

d)

char gender[80] = new char[ ];

12.

Arrange the following java statements in the correct order of execution to accept values into the array a[]:

(i) a[i]=sc. nextInt( );

(ii) int a[]=new int[10];

(iii) Scanner sc=new Scanner(System. in);

(iv) for(i=0;i<10;i++)

a)

(i), (ii), (iii), (iv)

b)

(ii), (iii), (iv), (i)

c)

(iv), (iii), (ii), (i)

d)

(iii), (i), (iv), (ii)

13.

What is the highest index of any array with 100 elements?

a)

100

b)

101

c)

99

d)

98

14.

Mr. Sanjay is an event manager, he plans and allots duties to each of his subordinates to handle different events. In a program, a task is divided into simple methods. Name the feature used in these contexts.

a)

Complexity

b)

Modularity

c)

Reusability

d)

Monolithic

15.

Raj was asked to accept the phone number which has 10 digits, using the appropriate method of Scanner class. Which of the following statement he must choose?

a)

Ob. nextInt()

b)

Ob. nextDouble()

c)

Ob. nextLong()

d)

Ob. next().chatAt(0)

16.

Raj wanted to count the number of digits in a given number without using a loop. Which of the following statements is correct to perform the above?

a)

String.valueOf(n).length()

b)

Integer.parseInt(n).length()

c)

n.length()

d)

All the above

17.

Sham was asked to encode a string S, by replacing the letter E with #. Select the appropriate statement:

a)

S.replace('#','E')

b)

S.replace('E')

c)

S.replace('E', '#')

d)

S. replace('#')

18.

When the String m is compared to n, the result obtained is greater than zero. Which of the following is true?

a)

m comes before n in the dictionary.

b)

n comes before m in the dictionary.

c)

m and n are equal.

d)

m and n have the same length.

19.

Which of the following String methods has integer argument?

(i) length

(ii) substring

(iii) indexOf

(iv) charAt

a)

Only (ii)

b)

(i) and (iv)

c)

(ii) and (iv)

d)

(iii) and (iii)

20.

Assertion: Property by virtue of which one class acquires the properties of another class is termed as Inheritance.

Reason: Inheritance promotes reusability

(a) Assertion is true, Reason is false.

(b) Assertion is true, Reason is true.

(c) Assertion is false, Reason is false.

(d) Assertion is false, Reason is true.

a)

Assertion is true, Reason is false.

b)

Assertion is true, Reason is true.

c)

Assertion is false, Reason is false.

d)

Assertion is false, Reason is true.

21.

Which of the following is NOT true for polymorphism?

a)

All methods have the same name.

b)

Methods are invoked based on the arguments.

c)

Methods should have the same number and the same type of arguments.

d)

It is a principle of OOPs.

22.

Which of the following is a valid initialisation statement?

a)

int x = “GOOD”;

b)

int y = 45.0/2;

c)

int z=(int) ‘x’;

d)

int m = false ;

23.

Which of the following is a valid statement to print the following sentence: Raj said “Good morning”

a)

System. out. println(“Raj said “Good morning””);

b)

System. out. println(“Raj said \\|Good morning\\|”);

c)

System. out. println(“Raj said \"Good morning\" ” );

d)

System. out. println(“Raj said Good morning”);

24.

Which data structure is represented in the above picture?

a)

Both (i) and (ii)

b)

A one-dimensional array with 14 elements.

c)

Only (ii)

d)

Only (i)

e)

A two-dimensional array with 2 rows and seven columns.

25.

What is the type of looping statement depicted in the above picture?

a)

Entry controlled loop

b)

Exit controlled loop

c)

Multiple branching statement

d)

All the above.

26.

What is the process done in the above picture?

a)

Sorting the list in descending order

b)

Searching the character in the list

c)

Sorting the list in ascending order.

d)

None of the above.

27.

Name the method of search depicted in the above picture.

a)

Binary Search

b)

Selection Sort

c)

Bubble Sort

d)

Linear Search

28.

Name the feature of Java depicted in the above picture.

a)

Encapsulation

b)

Inheritance

c)

Polymorphism

d)

Data abstraction

29.

Name the data types in order from top, given in the above picture.

a)

int, char, double, String

b)

String, int, char, double

c)

char, double, int, String

d)

int, double, char, String

30.

How many bytes are occupied by the above two-dimensional array?

a)

96 bytes

b)

128 bytes

c)

12 bytes

d)

24 bytes

31.

A girl wanted to calculate the sum of two numbers stored as a and b multiplied by 7. Select the appropriate Java expression.

a)

a+b*7

b)

7*a+b

c)

(a+b)*7

d)

a+7*b

32.

The sum of a[1] and a[3] in the array int a[]={20,40,60,80,100} is:

a)

80

b)

100

c)

120

d)

60

33.

State which access specifier is less restrictive.

a)

private

b)

protected

c)

default

d)

public

34.

The AMB hotel gives the amount to be paid by the customer as an integer, which of the following Math method rounds off the bill in decimals to an integer?

a)

Math.round()

b)

Math.pow()

c)

Math.ceil()

d)

Math.abs()

35.

Identify which of the following leads to an infinite loop.

a)

for(i=10;i!=0;i--)

b)

for(i=3;i<=30;i+=3)

c)

for(i=1;i>=1;i++)

d)

for(i=1;i>=0;i--)

36.

Assertion: A class can have multiple constructors

Reason: Multiple constructors are defined with same set of arguments.

(a) Assertion is true, Reason is false.

(b) Both assertion and Reason are false.

(c) Both assertion and Reason are true.

(d) Assertion is false, Reason is true.

a)

Assertion is true, Reason is false.

b)

Both assertion and Reason are false.

c)

Both assertion and Reason are true.

d)

Assertion is false, Reason is true.

37.

Assertion: An array can store elements of different data types

Reason: An array is a user-defined data type with multiple values of the same data type but a different memory index.

(a) Assertion is true, Reason is false.

(b) Both Assertion and Reason are false.

(c) Both Assertion and Reason are true.

(d) Assertion is false, Reason is true.

a)

Assertion is true, Reason is false.

b)

Both Assertion and Reason are false.

c)

Both Assertion and Reason are true.

d)

Assertion is false, Reason is true.

38.

Which of the following statement is an example for explicit typecasting?

a)

int amount = 45;

b)

int amount = 24*24;;

c)

int amount = Integer.parseInt ("45");

d)

int amount = int (45.75);

39.

The output of the statement Math.ceil.(89.9)+Math.floor(90.5) is:

a)

0.0

b)

180

c)

180.0

d)

180.4

40.

The output of the statement of “TIGER”. indexOf(‘G’) is:

a)

3

b)

2

c)

-1

d)

0

41.

Choose the statement which is equivalent to the given: if(a>b) System.out. println(“Honest”); else System.out.println(“Sincere”);

a)

a>b? System.out. println(“Honest”):System.out.println(“Sincere”);

b)

System.out.println(a>b? “Honest”: “Sincere”);

c)

a>b? “Honest”: “Sincere”;

d)

a>b: “Honest”? “Sincere”;

42.

The two Java statement are used to check for the equality of the strings “COP” and “cop” are as follows:

“COP”. equals(“cop”) “COP”. equalsIgnoreCase(“cop”)

The output of the above statements is:

a)

false, true

b)

true, false

c)

false, false

d)

true, true

43.

The output of the java statement “SOLDIER”. compareTo(“SOLUTE”); is

a)

-4

b)

-17

c)

17

d)

0

44.

Arrange the following in the descending order of number of bytes occupied.

(i) char x[20]

(ii) int a[4][2]

(iii) double b[6]

a)

(iii), (ii), (i)

b)

(iii), (i), (ii)

c)

(ii), (iii), (i)

d)

(i), (ii), (iii)

45.

Sam performs bubble sort on the following array to organise the elements in ascending order: {5,1,2,3} After the first comparison the array is: {1,5,2,3} What would be the array after the next comparison?

a)

{1,2,5,3}

b)

{1,5,3,2}

c)

{1,3,5,2}

d)

{1,3,2,5}

46.

Write the java statement for: Sum of a raised to b and cuberoot of c

a)

Math.pow(a, b) + Math.cbrt(c);

b)

Math.pow(b, a) + Math.cbrt(c);

c)

Math.pow(a, b) + Math.sqrt(c);

d)

Math.pow(a, b) + Math.cbrt(b);

47.

Name the following: (a) Method with the same name as of the class and is invoked every time an object is created. (b) Keyword to access the classes of a package.

a)

Constructor import

b)

Destructor package

c)

Instantiator class

d)

Initializer extends

48.

Name the following: (a) A Character method that checks whether a character is an alphabet or a number. (b) A Math method that does not have an argument.

a)

isLetterOrDigit(char ch) (b) random()

b)

isDigit(char ch) (b) abs()

c)

isAlphabet(char ch) (b) sqrt()

d)

isLetter(char ch) (b) pow()

49.

Cyber police wanted to investigate a case; they wanted to check a list of phone numbers that had 945 anywhere in the phone number. Example: 7394567938, 7685483945..., a method was created to convert the phone number in long data type to a string and check for the existence of the number 945. void check(long pno) { String s = ______(a)_________; if(______(b)_______) System.out.println(pno); } Which of the following options correctly fills the blanks (a) and (b)?

a)

Long.toString(pno) s.contains("945")

b)

String.valueOf(pno) s.equals("945")

c)

pno.toString() s.indexOf("945") == -1

d)

s = pno + "" s.startsWith("945")

50.

A manager wants to check the number of employees with names ending with KUMAR, and fill in the blanks in the given program segment with appropriate Java statements:

void count(String s[]) {
int i, l=__________, c=0;
for(i=0;i if(________________)
c++;
}
System.out.println(c);
}

Which of the following options correctly fills the blanks?

a)

l=s.length
s[i].endsWith("KUMAR")

b)

l=s.size()
s[i].contains("KUMAR")

c)

l=s.length()
s[i].equals("KUMAR")

d)

l=s.count
s[i].endsWith("KUMAR")

51.

Which of the following Java statements will output "PASS" and "PASSION" from the string "COMPASSION"?

a)

System.out.println(str.substring(4,8)); System.out.println(str.substring(4));

b)

System.out.println(str.substring(0,4)); System.out.println(str.substring(0,7));

c)

System.out.println(str.substring(3,7)); System.out.println(str.substring(3));

d)

System.out.println(str.substring(5,9)); System.out.println(str.substring(5));

52.

Give the output of the following program segment: for(k=a; k<=a*b; k+=a) { if (k%b==0) break; } System.out.println(k); Give the output when a=6, b=4.

a)

12

b)

6

c)

18

d)

24

53.

Kamal wants to display only the alphabets stored in a character array. While compiling the code, an error was displayed. Check for the statement with the error and write the correct statement.

a)

for(int i=0; i='A' && arr[i]<='Z') || (arr[i]>='a' && arr[i]<='z')) printf("%c", arr[i]); }

b)

for(int i=0; i

c)

for(int i=0; i='0' && arr[i]<='9') printf("%c", arr[i]); }

d)

for(int i=0; i

54.

Name the type of type casting in the given statements: (a) double m = 'b'; (b) char ch = (char) 68;

a)

Implicit casting (b) Explicit casting

b)

Explicit casting (b) Implicit casting

c)

Implicit casting (b) Implicit casting

d)

Explicit casting (b) Explicit casting

55.

[Mathematical Library Methods; String Handling] Which of the following Java statements correctly assigns the cube root of -343 to a variable and the position of the last occurrence of '@' in the String s? (a) double x = Math.cbrt(-343); int pos = s.lastIndexOf('@'); (b) int x = Math.sqrt(-343); int pos = s.indexOf('@'); (c) double x = Math.pow(-343, 3); int pos = s.indexOf('@'); (d) int x = Math.cbrt(-343); int pos = s.lastIndexOf('@');

a)

double x = Math.cbrt(-343); int pos = s.lastIndexOf('@');

b)

int x = Math.sqrt(-343); int pos = s.indexOf('@');

c)

double x = Math.pow(-343, 3); int pos = s.indexOf('@');

d)

int x = Math.cbrt(-343); int pos = s.lastIndexOf('@');

56.

Mention the output of this code snippet: int lives = 5; System.out.println(lives--); System.out.println(lives);

a)

5 4

b)

4 5

c)

5 5

d)

4 4

57.

Convert the following for loop segment to an exit-controlled loop.

a)

while(k>=-1) { System.out.println(k*2); System.out.println(k*4); k--; }

b)

do { System.out.println(k*2); System.out.println(k*4); k--; } while(k>=-1);

c)

while(k>-1) { System.out.println(k*2); System.out.println(k*4); k++; }

d)

do { System.out.println(k*2); System.out.println(k*4); k++; } while(k>=-1);

58.

Give the output of the following program segment: int x[]={2,45,7,67,12,3}; int i, t=0; for(i=0, t=5;i<3;i++,t--) { System.out.println(x[i]+x[t]); }

a)

49 52 19

b)

47 50 17

c)

49 45 19

d)

49 52 17

59.

Write Java statements for the following: (a) Initialise the array with the three favourite subjects. (b) Declare an array to store the marks in 3 subjects of 40 students.

a)

String subjects[] = {"Math", "Science", "English"}; (b) int marks[][] = new int[40][3];

b)

int subjects[] = {"Math", "Science", "English"}; (b) int marks[] = new int[3][40];

c)

String subjects = {"Math", "Science", "English"}; (b) int marks[][] = new int[3][40];

d)

String subjects[] = {Math, Science, English}; (b) int marks[][] = new int[40][3];

60.

A Student executes the given program segment and it results in 1.0, irrespective of the value of n. State the type of the error, write the correct statement: void solve(int n) { double power=Math.pow(n, ⅔); System.out.println(power); }

a)

Type of error: Integer division error (⅔ evaluates to 0). Correct statement: double power = Math.pow(n, 2.0/3.0);

b)

Type of error: Syntax error due to invalid character. Correct statement: double power = Math.pow(n, 2/3);

c)

Type of error: Data type mismatch. Correct statement: double power = Math.pow(n, ⅔.0);

d)

Type of error: Logical error in exponent. Correct statement: double power = Math.pow(n, 3.0/2.0);

61.

Consider the following program segment: for(int k=1;k<=5;k++) { System.out.println(k); System.out.println(k); } Will the program segment get executed successfully?

a)

Yes, the program will execute successfully and print each value of k twice.

b)

No, there is a syntax error in the for loop declaration.

c)

No, System.out.println cannot be used inside a loop.

d)

No, the loop will not terminate.

62.

Consider the array: int a[]={12,35,40,22,56,9,70}; How many iterations are required to check for the existence of the value 56 using linear search in the given array? (a) 5 (b) 4 (c) 6 (d) 3

a)

5

b)

4

c)

6

d)

3

63.

Evaluate the expression: 3*6%5*4/2*7%5

a)

2

b)

4

c)

1

d)

3

64.

Consider the following program which calculates the Norm of a matrix. Norm is square root of sum of squares of all elements. double norm() { int x[][]={{1,5,6},{4,2,9},{6,1,3}}; int r, c, sum=0; for(r=0;r<3;r++) { for( c=0;c<3;c++) { sum=sum+______(a)_______; } } ______(b)_________; }

a)

x[r][c]*x[r][c] (b) return Math.sqrt(sum);

b)

x[r][c]+x[r][c] (b) return Math.pow(sum,2);

c)

x[r][c] (b) return sum;

d)

x[r][c]/x[r][c] (b) return Math.abs(sum);

65.

Give the output of the following program segment: for(r=1;r<=3;r++) { for(c=1;c

a)

2 3 3

b)

1 2 3

c)

2 3

d)

1 2

66.

Give the output of the following program segment: void encode() { String s= "DICE"; char ch; for(i=0;i<4;i++) { ch=s.charAt(i); if("AEIOUaeiou".indexOf(ch)>=0) System.out.println("@"); else System.out.println(ch); } }

a)

D @ C @

b)

D I C E

c)

@ @ @ @

d)

D I @ E

67.

What is the main condition to perform binary search on an array?

a)

The array must be sorted.

b)

The array must contain only positive numbers.

c)

The array must have an even number of elements.

d)

The array must not contain duplicate values.

68.

Name the following: (b) A sort method in which consecutive elements are NOT compared.

a)

Selection sort.

b)

Bubble sort.

c)

Insertion sort.

d)

Merge sort.

69.

Scanner class method to accept a character.

a)

next().charAt(0)

b)

nextInt()

c)

nextLine()

d)

nextDouble()

70.

Jump statement which stops the execution of a construct.

a)

break

b)

continue

c)

goto

d)

return

71.

How many times is the given loop executed? Give the output of the same.
for(k=10;k<=20;k+=4)
{
    System.out.println(k);
    if(k%3==0) continue;
}

a)

The loop is executed 4 times. Output:
10
14
18

b)

The loop is executed 3 times. Output:
10
14
18

c)

The loop is executed 5 times. Output:
10
14
18
22

d)

The loop is executed 2 times. Output:
10
14

72.

Define a class to accept the purchase amount and the number of years of the tenure, calculate and print the details as per the above specifications.

a)

A class with methods to input purchase amount and tenure, and calculate details.

b)

A class that only prints the purchase amount.

c)

A class that only accepts the number of years of tenure.

d)

A class that does not perform any calculations.

73.

Define a class to accept a four-digit number and check if it is a USHWA number or not. The number is said to be USHWA if: Sum of all digits = 2 × (sum of first and last). If the input value is 354, then an error message should be given as the number has only 3 digits. Which of the following conditions correctly defines a USHWA number?

a)

Sum of all digits = 2 × (sum of first and last)

b)

Sum of all digits = sum of first and last

c)

Sum of all digits = 4 × (sum of first and last)

d)

Sum of all digits = 3 × (sum of first and last)

74.

Which of the following best defines a class to print Floyd's triangle of given rows using nested loops only?

a)

A class with a method that uses nested loops to print Floyd's triangle for a given number of rows.

b)

A class that uses recursion to print Floyd's triangle for a given number of rows.

c)

A class that prints Floyd's triangle using a single loop for a given number of rows.

d)

A class that prints Pascal's triangle using nested loops for a given number of rows.

75.

What is the sum of the series 1+(1+2)+(1+2+3)+...+(1+2+3+...+20)?

a)

4410

b)

210

c)

1540

d)

20

76.

A student appearing for the ICSE/ISC examination will be given an index number, which is of the following format: Number of 7 digits/number of 3 digits. The first digit represents ICSE(1) or ISC(2), the next two digits represent the year, the next four digits represent the centre number, the last 3 digits represent the index number. Which digit in the index number format indicates whether the student is appearing for ICSE or ISC?

a)

The first digit

b)

The last digit

c)

The third digit

d)

The second digit

77.

Define a class to accept values into a 3x3 array and check if it is a Losho grid or not. A grid is a Losho grid if the sum of each row and column equals 15. Print appropriate messages. What should the class check to determine if the grid is a Losho grid?

a)

The sum of each row and column equals 15.

b)

The sum of each diagonal equals 15.

c)

The sum of all elements equals 15.

d)

The sum of each row equals 9.

78.

Which of the following correctly defines a class with overloaded 'perform' methods as described below? void perform(int x[]) - displays the largest element of the array. void perform(String s, char ch) - if ch is 'F', prints the first 5 characters; if ch is 'L', prints the last 5 characters. void perform(int n) - prints the product of the first and last digits of the number.

a)

A class with three 'perform' methods, each with different parameter types as described.

b)

A class with a single 'perform' method that uses if-else statements to handle all cases.

c)

A class with three 'perform' methods, all taking the same parameter types.

d)

A class with two 'perform' methods, one for arrays and one for strings.

79.

Name the element of Java used in the program. Define a class with the four methods with the same name.

a)

Method Overloading

b)

Inheritance

c)

Polymorphism

d)

Encapsulation

80.

Define a class to accept the marks of 100 students in an array and print the statistics as mentioned above.

a)

A class with an array to store 100 marks and methods to print statistics.

b)

A class with a single integer variable to store marks.

c)

A class with an array to store 10 marks and no methods.

d)

A class with a string variable to store student names only.

81.

Define a class to accept a password and check whether the password is strong or not.

a)

A class that takes a password and checks its strength.

b)

A class that encrypts passwords only.

c)

A class that stores passwords without validation.

d)

A class that generates random passwords.

82.

Which of the following methods can be used to check if a character is a letter or digit in Java?

a)

Character.isLetterOrDigit(char)

b)

Math.random()

83.

Which of the following statements converts a string to a value in Java?

a)

s=String.toValue(pno)

b)

s.indexOf("945")>=0

84.

To get the length of a string in Java, use _______.

a)

s.length

b)

s.size()

c)

length(s)

d)

s.len()

85.

To check if a string ends with 'KUMAR', use _______.

a)

s[i].endswith("KUMAR")

b)

s[i].startswith("KUMAR")

c)

s[i].contains("KUMAR")

d)

s[i].end("KUMAR")

86.

Which of the following will return the substring from index 3 to 7 in the string "COMPASSION"?

a)

"COMPASSION".substring(3,7)

b)

"COMPASSION".substring(3)

87.

Given the following values: a b k 6 4 6 (6%4 is not zero) 6 4 12 (12%4 is zero) What is the output?

a)

6 4 6 (6%4 is not zero) 6 4 12 (12%4 is zero)

b)

6 4 6 (6%4 is zero) 6 4 12 (12%4 is not zero)

c)

6 4 6 (6%4 is zero) 6 4 12 (12%4 is zero)

d)

6 4 6 (6%4 is not zero) 6 4 12 (12%4 is not zero)

88.

Identify the statement with error and provide the corrected statement:

a)

The statement with error is: 'Identify the statement with error and provide the corrected statement.' Corrected statement: 'Identify the statement with an error and provide the corrected statement.'

b)

The statement with error is: 'Identify the statement with error and provide the corrected statement.' Corrected statement: 'Identify the statement with error and provide the correct statement.'

c)

The statement with error is: 'Identify the statement with error and provide the corrected statement.' Corrected statement: 'Identify the statement with errors and provide the corrected statement.'

d)

The statement with error is: 'Identify the statement with error and provide the corrected statement.' Corrected statement: 'Identify the statement with error and provide a corrected statement.'

89.

Which of the following is implicit type casting?

a)

Implicit type casting

b)

Explicit type casting

90.

What is the value of double c after executing: double c = Math.cbrt(-343);

a)

-7.0

b)

7.0

c)

-49.0

d)

-343.0

91.

What is the value of int p after executing: int p = s.lastIndexOf('@');

a)

The index of the last occurrence of '@' in s

b)

The index of the first occurrence of '@' in s

c)

Always -1

d)

The length of s

92.

What are the output values for the following?

a)

0 and 1

b)

1 and 2

c)

2 and 3

d)

3 and 4

93.

What is the output?

a)

10

b)

20

c)

30

d)

40

94.

Given the following table, i t x[i] x[t] output 0 5 2 3 ___ 1 4 45 12 ___ 2 3 7 67 ___

a)

5, 57, 74

b)

2, 45, 67

c)

3, 12, 67

d)

5, 12, 7

95.

What is the correct way to declare and initialize the following in Java?

a)

int num = 10;

b)

int num; 10 = num;

c)

num int = 10;

d)

int = 10; num;

96.

Identify the error and provide the correct statement:

a)

There is a syntax error; the correct statement is 'int a = 5;'

b)

There is a logical error; the correct statement is 'int a = 10;'

c)

There is a runtime error; the correct statement is 'int a = 0;'

d)

There is no error; the statement is correct as it is.

97.

Is the following code correct? If not, state the error and correct it:

a)

The code is correct.

b)

The code has a syntax error.

c)

The code has a logical error.

d)

The code is missing a semicolon.

98.
a)

5

b)

2