0% found this document useful (0 votes)
6 views2 pages

Java Short Answers

The document provides short answers to Java-related questions, covering topics like data types, casting, literals, and type conversion. It distinguishes between implicit and explicit conversions, primitive and composite types, and explains default values and memory capacities. Each answer is concise, focusing on essential definitions and examples.

Uploaded by

Sagan Babu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Java Short Answers

The document provides short answers to Java-related questions, covering topics like data types, casting, literals, and type conversion. It distinguishes between implicit and explicit conversions, primitive and composite types, and explains default values and memory capacities. Each answer is concise, focusing on essential definitions and examples.

Uploaded by

Sagan Babu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java – Short Answers (15–20 words)

Q1. How is implicit conversion different from explicit conversion?


Implicit conversion happens automatically by the compiler, while explicit conversion is done
manually by the programmer using casting.

Q2. Give one example each of primitive and composite data type.
Primitive data type example: int. Composite data type example: array or class used to store
complex data.

Q3. State the values of n and ch.


Character 'A' has ASCII value 65. After adding one, n becomes 66 and ch becomes 'B'.

Q4. What is a literal?


A literal is a fixed constant value used directly in a program and assigned to variables.

Q5. What types of casting are shown?


(int)x shows explicit casting, while assigning an int value to long shows implicit casting.

Q6. Name the primitive data types.


A 64■bit integer data type is long. A single 16■bit Unicode character type is char.

Q7. Difference between floating point literal and double literal.


Floating point literals have smaller precision and range, while double literals provide higher
precision and a wider range.

Q8. Default values of int and float.


The default value of int is 0 and the default value of float is 0.0F.

Q9. What are identifiers?


Identifiers are names given to variables, classes, methods, and objects to identify them in a
program.

Q10. Identify the literals.


0.5 is a real literal, 'A' is character literal, false is boolean literal, and "a" is string literal.

Q11. Arrange primitive data types in ascending order.


Ascending order according to size is byte, char, int, and double.

Q12. Types of casting shown.


char c=(char)120 shows explicit casting, while int x='t' shows implicit casting by the compiler.
Q13. Difference between primitive and composite data types.
Primitive types store simple values directly, whereas composite types store complex data structures
like arrays and classes.

Q14. Classify primitive and non■primitive types.


char and int are primitive data types, while arrays and classes are non■primitive data types.

Q15. Memory capacity of short and float.


The short data type occupies 2 bytes of memory, while float occupies 4 bytes.

Q16. Identify the tokens.


public is a keyword, 'a' is character literal, == is operator, and { } are separators.

Q17. Difference between float and double initialization.


Float values are initialized using suffix F, while double values use suffix D or no suffix.

Q18. What do you mean by type conversion?


Type conversion is the process of converting a value from one data type to another.

You might also like