1. Name any two OOP principles.
2. Mention two different styles of expressing
a comment in a program.
3. Differentiate between operator and
expression.
4. 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
5. What is a compound statement? Give an
example.
6. What will be the output of the following
if x=5 initially?
i) 5 * ++x
ii) 5 * x++
7. What is the output of the following?
char c = 'A';
short m = 26;
int n = c+m;
System.out.println(n);
8. Define encapsulation.
9. Explain the term object using an example.
10. Define a variable.
11. What is a wrapper class? Give an example.
12. What is the purpose of the new operator?
13. State the two kinds of data types.
14. Write the corresponding expressions for
the following mathematical operations :-
i) a2 + b2
ii) z = x3 + y3 – xy
---
z
15. What is meant by private visibility of a
method?
16. 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);
17. What is a package? Give an example.
18. Name two types of Java programs.
19. Assign the value of pi (3.142) to a
variable of requisite data type.
20. Explain the term type casting.
21. Name the following:
i) A package that is invoked by default.
ii) A keyword, to use the classes defined in
a package.
22. Name the class that is used for different
mathematical functions. Give an example of a mathematical function.
23. State the difference between = and ==.
24. Write an equivalent Java syntax for the
following expression:
a = 0.05 - 2y3 / x - y
25. 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
26. What is the output of the following?
i) System.out.println ("four :" + 4
+ 2);
ii)System.out.println
("four :" + (2+2));
27. Evaluate the following expressions, if
the values of the variables are a = 2, b=3 and c=9
1. a - (b++) * (- -c)
2. a * (++b) % c
28. Mention any two attributes required for
class declaration.
29. State the difference between token and
identifier.
30. What is inheritance and how is it useful
in Java?
31. Explain any two types of access
specifier.
32. If a=5, b=9 calculate the value of: a +=
a++-++b+a
33. 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);
34. What does the following mean?
Employee stuff = new Employee();
35. Write a Java statement to input / read
the following from the user using the keyboard:
i) Character ii) String
36. Why is a class called a factory of
objects?
37. State the difference between a boolean
literal and a character literal.
38. Write one word answer for the following:
i) A method that converts a string to a
primitive integer data type
ii) The default initial value of a boolean
variable data type
39. Why is a class known as a composite data
type?
40. Write an expression for (a + b)n
----———
v3
+ b
41. Define the term byte code.
42. What do you mean by type conversion? How
is implicit conversion different from explicit conversion?
43. What is the result stored in x, after
evaluating the following expression?
44. int x = 5;
45. x = x++ * 2 + 3 * --x;
46. Differentiate between private and
protected visibility modifiers.
47. What do you understand by the term data
abstraction?
48. What will the following functions return
when executed?
i) Math.max(-17,-19) ii) Math.ceil(7.8)
i) Why is an object called an instance of a
class?
ii) What is the use of the keyword import?
49. What is the difference between an object
and a class?
50. What does the ‘token’ keyword refer to,
in the context of Java? Give an example for keyword.
51. What is the difference between the / and
% operators?
i) Name the package that contains Scanner
class
ii) Which unit of the class gets called, when
the object of the class is created?
52. What is the role of keyword void in
declaring functions?
53. What will be the output of the following
code?
i) int k = 5, j = 9;
k+=k++ - ++j + k;
System.out.println("k= " +k);
System.out.println("j= " +j);
ii) double b = -15.6;
double
a = Math.rint (Math.abs (b));
System.out.println("a="
+a);
54. Write an expression in Java for z = (5x3
+ 2y ) / ( x + y)
55. Give one example each of a primitive data
type and a composite data type.
56. Give one point of difference between
unary and binary operators.
57. Write a Java expression for v(2as + u2)
58. Name the type 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 semi colon.
59. Complete the code below to create an
object of Scanner class.
Scanner
sc = _____ Scanner( _____ );
60. Differentiate between public and private
modifiers for members of a class.
61. What will be the result stored in x after
evaluating the following expression?
int
x=4;
x+=(x++)
+ (++x) + x;
62. Give the output of the following program
segment:
double
x = 2.9, y = 2.5;
63.
System.out.println(Math.min(Math.floor(x),y));
64.
System.out.println(Math.min(Math.ceil(x),y));
65. What is meant by precedence of operators?
66. What is a literal?
67. 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;
68. Name any two wrapper classes.
69. Write Java statement to create an object
mp4 of class digital.
70. What does a class encapsulate?
71. What is the data type that the following
library functions return?
Math.random()
Math.floor()
Math.sqrt()
Math.pow()
72. Write a Java expression for ut + ½ ft2
73. Name the methods of the Scanner class
that:
i) Is used to input an integer from standard
input stream
ii) Is used to input a string data from
standard input stream
74. Which of the following are valid
comments?
(i) /* comment */
(ii) /* comment
(iii) // comment
(iv) */ comment */
75. 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'.
76. State one difference between the floating
point literals float and double.
77. 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) ++
78. 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++;
79. 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));
80. Give the 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);
}
No comments:
Post a Comment