Saturday, 16 June 2018

Standard IX SECTION A FOR FIRST TERM 2018

  1. Name any two OOP principles.
  2. State the Java concept that is implemented through:
i)                    A super class and a subclass.
ii)                   The act of representing essential features without including background details.
  1. Which OOP principle implements function overloading?
  2. Define encapsulation.
  3. What is inheritance and how is it useful in Java?
  4. What is a package? Give an example.
  5. Name two types of Java programs.
  6. Name the following:
i)                    A package that is invoked by default.
ii)                   A keyword, to use the classes defined in a package.
  1. Define the term Byte Code.
  2. Name of the following:
i)                             A keyword used to call a package in the program.
ii)                            Any one reference data types.
  1. Name the types of error (syntax, runtime or logical error) in each case given below:
(i) Division by a variable that contains a value of zero.
(ii) Multiplication operator used when the operation should be division.
(iii) Missing semicolon.
  1. What will be the output when the following code segments are executed?
String s = "1001";
int x = Integer.valueOf(s);
double y = Double.valueOf(s);
System.out.println("x=" +x);
System.out.println("y=" +y);
13.   Give the output of the following code:
String A= "26", B= "100";
String D=A+B+ "200";
int x= Integer.parseInt(A);
int y=Integer.parseInt(B);
int d=x+y;
System.out.println("Result 1="+D);
System.out.println("Result 2="+d);
14.   Mention two different styles of expressing a comment in a program.
  1. Differentiate between operator and expression.
  2. If m=5 and n=2 output the values of m and n after execution in (i) and (ii) :-
i) m -= n;
ii) n = m + m/n
  1. What is a compound statement? Give an example.
  2. What will be the output of the following if x=5 initially?
i) 5 * ++x
ii) 5 * x++
19.   What is the output of the following?
char c = 'A';
short m = 26;
int n = c+m;
System.out.println(n);
20.   Define a variable.
  1. State the two kinds of data types.
  2. Find the output of the following program segment, when:
i) val = 500 ii) val = 1600
        int val, sum, n=550;
        sum = n + val > 1750 ? 400 : 200;
        System.out.println(sum);
  1. What will be the output for the following program segment?
int a=0, b=30, c=40;
a = --b + c++ + b;
System.out.println("a=" + a);
24.   Assign the value of pi (3.142) to a variable of requisite data type.
  1. Explain the term type casting.
  2. State the difference between = and ==.
  3. Write an equivalent Java syntax for the following expression: a = 0.05 − 2y3 / x − y 
  4. Rewrite the following using ternary operator:
if(income < 10000)
tax = 0;
else
tax = 12;
29.   Write a statement for each of the following:
1. Store a number 275 as a String
2. Convert the String to a numeric value
3. Add it to the existing total of 1000 to update the field
  1. What is the output of the following?
i) System.out.println ("four :" + 4 + 2);
ii) System.out.println ("four :" + (2+2));
  1. Evaluate the following expressions, if the values of the variables are   a = 2, b=3 and c=9
i) a − (b++) * (− −c)
ii) a * (++b) % c        
32.   Give the output of the following expressions:
i) If x = -9.99, calculate Math.abs(x);
ii) If x = 9.0, calculate Math.sqrt(x);
  1. State the difference between a boolean literal and a character literal.
  2. What is the use and syntax of a ternary operator?
35.   What will be the output of the following code?
char x = 'A' ; int m;
m=(x=='a') ? 'A' : ‘a’;
System.out.println("m="+m);
36.   What will the following functions return when executed?
(j) Math.max(-17, -19)
(ii) Math.ceil(7.8)
  1. What will be the result stored in x after evaluating the following expression?
int x=4;
x += (x++) + (++x) + x;
  1. Give the output of the following program segment:
double x = 2.9, y = 2.5;
System.out.println(Math.min(Math.floor(x), y));
System.out.println(Math.max(Math.ceil(x), y));
  1. What is meant by precedence of operators?
  2. What are the types of casting shown by the following examples?
i) double x =15.2;
int y =(int) x;
ii) int x =12;
long y = x;
  1. Write a Java expression for ut + ½ ft2
  2. What is the data type that the following library functions return?
i) isWhitespace(char ch)
ii) Math.random()
  1. Which of the following are valid comments?
(i) /* comment */
(ii) /*comment
(iii) //comment
(iv) */ comment */
  1. Name the primitive data type in Java that is:
(i) a 64-bit integer and is used when you need a range of values wider than those provided by int.
(ii) a single 16-bit Unicode character whose default value is ‘\u0000'
  1. State one difference between floating point literals float and double.
  2. Operators with higher precedence are evaluated before operators with relatively lower precedence. Arrange the operators given below in order of higher precedence to lower precedence.(i) && (ii) % (iii) >= (iv) ++
  3. Identify the statements listed below as assignment, increment, method invocation or object creation statements.
(i) System.out.println(“Java”);
(ii) costPrice = 457.50;
(iii) Car hybrid = new Car();
(iv) petrolPrice++;
  1. Give the output
System.out.println("The King said \"Begin at the beginning!\" to me.");
  1. What are the final values stored in variables x and y below?
double a = - 6.35;
double b = 14.74;
double x = Math.abs(Math.ceil(a));
double y = Math.rint(Math.max(a,b));
  1. Give output of the following method:
public static void main(String[] args) {
int a = 5;
a++;
System.out.println(a);
a -= (a--) - (--a);
System.out.println(a);
51.   Explain, with the help of an example, the purpose of default in a switch statement.
  1. Differentiate between if and switch statements.
  2. Explain with an example, the if..else if construct.
  3. The following is a segment of a program.
x = 1; y = 1;
if(n > 0)
{
    x = x + 1;
    y = y - 1;
}
  1. What will be the value of x and y, if n assumes a value (i) 1 (ii) 0?
  2. Give the output of the following code segment when (i) opn = ‘b’ (ii) opn = ‘x’ (iii) opn = ‘a’.
switch(opn)
{
    case 'a':
      System.out.println("Platform Independent");
      break;
    case 'b':
      System.out.println("Object Oriented");
    case 'c':
      System.out.println("Robust and Secure");
      break;
    default:
      System.out.println("Wrong Input");
}
  1. Rewrite the following program segment using the if..else statement.
comm =(sale>15000)?sale*5/100:0;
  1. Give two differences between switch statement and if-else statement.
  2. Rewrite the following program segment using the if-else statements instead of the ternary operator.
  3. String grade = (mark >= 90) ? "A" : (mark >= 80) ? "B" : "C";
  4. What are the values of x and y when the following statements are executed?
int a = 63, b = 36;
boolean x = (a < b ) ? true : false; int y= (a > b ) ? a : b ;
  1. Evaluate the value of n if value of p=5,q=19
int n =  (q-p)>(p-q)?(q-p) : (p-q);
  1. Rewrite the following using ternary operator :
if(x%2 == 0)
System.out.print(“EVEN”);
else
System.out.print(“ODD”);




No comments:

Post a Comment