-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataTypes_Casting_assignment.txt
More file actions
47 lines (37 loc) · 2.33 KB
/
DataTypes_Casting_assignment.txt
File metadata and controls
47 lines (37 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Que 1. What are Primitive data types in Java?
Ans: byte, short, int, long, float, double, char, String, boolean
Que 2. What are the Identifiers in Java?
Ans: Identifiers in Java are symbolic names used for identification. They can be a class name, variable name,
method name, package name, constant name, and more. However, In Java , There are some reserved words
that can not be used as an identifiers.
Que 3. What is final class in Java?
Ans: A class declared with a final keyword is called final class. It does not allow itself to be inherited by another
classes.
Que 4. What are the two ways to make a class final?
Ans: The first way to make a final class is to declare a class with final keyword. Another way is to declare all of
its constructors as private. If a class has only private constructors, it cannot be subclassed.
Que 5. Can we create an instance of final class in another class?
Ans: Does, we can create an instance of final class in another class but cannot be inherited.
Que 6. What is Volatile keyword used for ?
Ans7 Volatile is a declaration that a variable can be accessed by multiple threads and hence shouldn't be
cached.
Que 7. What is the use of Transient Keyword ?
Ans7 It in Java is used to indicate that a field should not be serialized.
Que 8. What are the types of casting?
Ans: There are two types of casting.
1. Primitive Casting: When the data is casted from one primitive type(like int, float, double etc...) to another
primitive type, then it is called primitive casting.
2. Derived Casting:When the data is casted from one derived type to another derived type, then it is called
derived casting.
Que 9. What is boxing and unboxing?
Ans: Wrapping of primitive content into corresponding Wrapper class object is called boxing. Unwrapping the
wrapper class object into corresponding primitive content is called unboxing.
Que 10. What is the difference between keywords, identifiers and literals in java ?
Ans: Keywords are the reserved words that have a pre defined meaning for the compiler and hence are
restricted to be used as identifiers.
Identifiers are the name assigned to different programming constructs like classes, interfaces, methods ,
variables etc.
Literals are the values that are assigned to Identifiers.
For example
int count = 0;
in the above statement "int" is a keyword, "count" is an identifier and "0" is a literal