Академический Документы
Профессиональный Документы
Культура Документы
Tokens
Name the keyword that: (2009)
i) is used for allocating memory to an array
ii) causes the control to transfer back to the method call
Ans.
i) new
ii) return
What does the token ‘keyword’ refer to in the context of Java? Give an example for keyword.
(2011)
Ans.
Keywords are reserved words which convey special meanings to the compiler and cannot be
used as identifiers. Example of keywords : class, public, void, int
Name the keyword that: (2011)
(i) informs that an error has occurred in an input/output operation.
(ii) distinguishes between instance variable and class variables.
Ans.
(i) Throw (ii) static
What are keywords? Give an example(2016)
Ans
Keywords are the words that convey a special meaning to the language Compiler. These are
reserved for special purpose and must not be used as normal identifiers
Arrange the following primitive data types in an ascending order of their size: (2015)
(i) char (ii) byte (iii) double (iv) int
Ans
(b) (i) byte (ii) char (iii) int (iv) double
Name the keyword which: (2019)
(i) indicates that a method has no return type.
(ii) makes the variable as a class variable.
Ans
(i) void
(ii) static
Write the memory capacity (storage size) of short and float data type in bytes (2019)
Ans
short – 2 bytes
float – 4 bytes
Identify and name the following tokens: (2019)
(i) public
(ii) 'a'
(iii) ==
(iv) { }
Ans
(i) Keyword
(ii) character literal /constants
(iii) operator
(iv) separator/punctuator
Write one-word answer for the following: (2009)
2
16-digit precision
List the variables from those given below that are composite data types. (2014)
(i) static int x;
(iv) boolean b;
(ii) arr[i]=10;
(v) private char chr;
(iii) obj.display();
(vi) String str;
Ans
(a) (ii) arr (iii) obj (vi) str
What are the default values of primitive data type int and float? (2015)
Ans
The default value of int is 0 and that of float is 0.0f
Name the wrapper classes of char type and boolean type. (2015)
Ans
Character and Boolean
What is a literal? (2013)
Ans.
A literal is a constant data item. There are different literals like integer literals, floating point
literals and character literals.
State the difference between a boolean literal and a character literal. (2009)
Ans.
i) A boolean literal can store one of two values – true and false. A character literal can store a
single Unicode character.
ii) The memory required by a boolean literal depends on the implementation. The memory
required by a character literal is 2 bytes.
What are identifiers? (2015)
Ans
An identifier is a sequence of characters used to name variables , methods, classes, packages and
interfaces OR They represent names of different components of a Java program.
Identify the literals listed below: (2015)
(i) 0.5 (ii) 'A' (iii) false (iv) "a".
Ans
(i) floating point literal
(ii) character literal.
(iii) boolean literal.
(iv) String literal
What do you understand by type conversion? (2010)
Ans.
Type conversion or casting is the conversion of the data type of a literal from one type to
another. There are two types of types of casting – implicit casting and explicit casting.
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;
4
Ans
i) Explicit casting
ii) Implicit casting
What are the types of casting shown by the following examples: (2016)
(i) char c = (char)120;
(ii) int x = 't';
Ans
(i) explicit type casting
(ii) implicit type casting
Identify the statements listed below as assignment, increment, method invocation or
object creation statements. (2014)
(i) System.out.println("Java");
(ii)cost Price = 457.50;
(iii)Car hybrid = new Car();
(iv)petrol Price++;
Ans
(i)method invocation
(ii)assignment
(iii) object creation
(iv) increment
What will be the output when the following code segments are executed? (2014)
(i) System.out.println("The king said \"Begin at the beginning!\" to me.");
Ans
(i) The king said “Begin at the beginning!”to me
Write down java expression for
T =√ A 2 +B 2+ C2
Ans
Math.sqrt(Math.pow(A,2)+ Math.pow( B,2)+ Math.pow(C,2)) OR
Math.sqrt((A*A+B*B+C*C))
Give the output of the following expression : (2016)
a+= a++ + ++a + --a + a-- ;
when a = 7
Ans
(i) a = 7 + 7 + 9 + 8 + 8 = 39
Write the output: (2017)
char ch = 'F';
int m = ch;
m=m+5;
System.out.println(m + " " + ch);
Ans
75 F
int res = 'A';
What is the value of res? (2018)
Ans 65
State the data type and value of res after the following is executed: (2019)
char ch = '9';
5
res= Character.isDigit(ch);
Ans
(i) boolean (ii) true