CLST 1:

Q1: Which of the following are valid comments?
1.   /* comment /
2.  / comment
3.  // comment
4.  */ comment */

Q2: Arrange the operators given below in order of higher precedence to lower precedence.
1. &&                   2. %
3. >=                    3. ++

Q3: Identify the statements listed below as assignments, increment, method invocation or object creation statements.
1. System.out.println(“JAVA”) ;
2. costPrice = 45.20 ;
3. Car hybrid = new Car() ;
4. price++ ;

Q4: State one difference between floating point literals float and double.

Q5: Name the primitive data types in java that is:
1: A 64-bit integer and is used when you need a range of values wider than those provided by int.
2. A single 16-bit Unicode character whose default value is ‘\u0000’ ?

Q6: What is meant by a package ? Name any two Java Application Programming Interface packages.

Answers —–>
Answer 1 :- (1) and (3) are valid comments. (1) type is used for multi-line comments and (3) is used for single line comment.In (2) ending / is missing and in (4) the start needs to be / not */.

Answer 2 :-
++, %, >=, &&

Answer 3:-
1. Method invocation
2. Assignment
3. Object creation
4. Increment

Answer 4:-
The Float data type is 4 bytes (32 bits) in size, and the double data type is 8 bytes (64 bits) in size.

Answer 5:-
1.  long
2. char

Answer 6:-
A package is a name given to a collection of classes. It is a mechanism for organizing classes and preventing name conflicts between classes. Java packages are stored as compressed JAR files; this also allows for faster downloading of class files as a group.Some Java API packages are: java.lang, java.util, java.io etc.  

Leave a comment