close
close

Download PDF with evaluation scheme

Download PDF with evaluation scheme

Question 1

Select the correct answers to the questions from the options provided.

(Do not copy the question, just write the correct answers.)

(i)Name the above structure:

(a) One-dimensional array

(b) Two-dimensional array with 4 rows and 5 columns

(c) Three-dimensional array

(d) Two-dimensional array with 5 rows and 4 columns

(ii) “Java compiled code (bytecode) can run on all operating systems”

— Name the function.

(a) Robust and safe

(b) Object-oriented

(c) Platform independent

(d) Multithreaded

(iii) The size of ‘\n ‘ is:

a) 2 bytes

b) 4 bytes

c) 8 bytes

d) 16 bytes

(iv) Identify the operator that has the highest precedence when evaluating the given expression:

a + b % c * d – e

(a) +

(B)%

(C )-

(D)*

(v) Which of the following is a valid Java keyword?

a) If

(b) BOOLEAN

c) static

(d) Switch

(vi)The output of the following code is:

System.out.println(Math.ceil(6.4)+Math.floor(-1-2));

a) 3.0

b)4

c)3

d)4.0

(vii) Which of the following returns a string?

(a) Length()

(b) charAt(int)

(c) replace(char, char)

(d) indexOf(string)

(viii) Which of the following statements is not true about a switch statement?

(a) checks whether the input and case names are the same

(b) supports floating point constants

(c) “break” is used to exit the switch block.

(d) Case names are clear

(ix) Consider the array given below:

char ch()={ ‘A’,’E’,’I’,’0′,’U’};

Write the output of the following statements:

System.out.println(ch(0)*2);:

a) 65

b) 130

c) “A”

d) 0

(x) Which of the following statements is correct to execute a loop 10 times?

(a) for (int i=11;i

(b) for (int i=11;i

(c) for (int i=11;i

(d) for (int i=11;i

(xi) A one-dimensional array has 50 elements. Which of the following statements is correct to initialize the last element to 100?

(a) x(51)=100

(b) x(48)=100

(c) x(49)=100

(d) x(50)=100

(xii) Method prototype for the method “compute”, which accepts two integer arguments and returns “true”/“false”.

(a) calculate void (int a, int b)

(b) Boolean calculation (int a, int b)

(c) Boolean calculation (int a,b)

(d) int calculate (int a, int b)

(xiii) The statement that returns control to the calling method is:

(a) Break

(b) System.exit(0)

c) continue

d) Return

(xiv)The default value of a Boolean variable is:

(a) False

b) 0

(c) false

(d) Correct

(xv) To convert a lowercase letter to an uppercase letter:

(a) String.toUpperCase( )

(b) Character.isUppercase ( char )

(c) Character.toUpperCase( char )

(d) in capital letters ()

(xvi) Assertion (A): The Integer class can be used in the program without calling a package.

Reason (R): It is part of the standard java.lang package.

(a) Both claim (A) and reason (R) are true and reason (R) is a correct explanation of claim (A).

(b)Both claim (A) and reason (R) are true and reason (R) is not a correct explanation for claim (A).

(c) Statement (A) is true and reason (R) is false

(d) Statement (A) is false and reason (R) is true

(xvii) A student executes the following code to increment the value of a variable ‘x’ by 2.

He wrote the following statement, which is false.

x=+2;

What would be the correct statement?

  1. x+=2;
  2. x=2;
  3. x=x+2;

a) Only A

b) Only C

c) All three

(d) Both A and C

(xviii) The statement used to determine the total number of strings present in the string array String s() is:

(a) see length

(b) s.length()

c) Length(s)

(d) Lens(s)

(xix) Consider the following program segment in which the statements are mixed up. Choose the correct order of statements to swap two variables using the third variable.

void swap(int a, int b)

{ a = b; → (1)

b=t;

int t=0;

t = on;

}

a) (1) (2) (3) (4)

b)(3) (4) (1) (2)

(c)(1) (3) (4) (2)

(d)(2) (1) (4) (3)

(xx)Assertion(A): An argument is a value that is passed to a method when it is called.

Reason(R): Variables declared in a method prototype to receive values ​​are called actual parameters.

(a) Both claim (A) and reason (R) are true and reason (R) is a correct explanation of claim (A).

(b) Both claim (A) and reason (R) are true and reason (R) is not a correct explanation for claim (A).

(c) Statement (A) is true and reason (R) is false

(d) Statement (A) is false and reason (R) is true

Question 2

(i) Rewrite the following code using a single if statement.

if (code = “g”)

System.out.println(“GREEN”);

else if (Code==’G’)

System.out.println(“GREEN”);

(ii) Evaluate the given expression if the value of a=2 and b=3.

b*=at++ – ++b + ++a;

System.out.println(“a= “+a);

System.out.println(“b=”+b);

(iii) A student executes the following program segment and gets an error. Identify the statement which contains an error and correct it to get the output as WIN.

Boolean value x = true;

Switch(x)

{ Case 1: System.out.println(“WIN”); interrupt;

Case 2: System.out.println(“LOOSE”);

}

(iv)Write the Java expression for
(v) How many times is the following loop executed? Write the output of the code:

int x=10;

while (true) {

System.out.println(x++ * 2);

if (x%3==0)

break;

}

(vi)Write the output of the following string methods:

String x = “Galaxy”, y = “Games”;

(a) System.out.println(x.charAt(0)==y.charAt(0));

(b) System.out.println(x.compareTo(y));

(vii)Predict the output of the following code snippet:

char ch=”B’;

char chr=Character.toLowerCase(ch);

int n=(int) chr-10;

System.out.println((char)n+”\t”+chr);

(viii) A student is trying to convert the string present in x into a numeric value so that he can find the square root of the converted value. However, the code has an error. State the error (syntax/logic/runtime). Fix the code so that it compiles and runs correctly.

String x=”25″;

int y=Double.parseDouble(x);

double r=Math.sqrt(y);

System.out.println(r);

(ix) Consider the following program segment and answer the following questions:

calculate class

{

int a; double b;

calculate()

{

a = 0;

b=0.0;

}

calculate(int x, double y)

{

a=x;

b = yes;

}

void sum()

{

System.out.println(a*b);

}}

Name the type of constructors used in the above program segment?

(x) Look at the following program section and answer the questions below:

intx()()={{2,4,5,6}. {5,7,8,1}, {34, 1,10, 9}};

(a) What is the position of 34?

(b) What is the result of x(2)(3) + x(1)(2)?

Leave a Reply

Your email address will not be published. Required fields are marked *