Page 147 - ComputerScience_Class_11
P. 147

6.8 CLASS AS MECHANISM FOR USER-DEFINED TYPE
                 A Java program is made up of classes and each class contains attributes (data members) that are predefined data types.
                 While creating an object of a class, we are basically defining a variable whose size is determined by the total bytes of
                 these predefined data types. A user-defined data type is a derived data type that depends on some existing data types.
                 Therefore, a class acts as a mechanism for creating user-defined data types.


                                Let’s Revisit



                       ♦ Every individual component used in Java code is known as a Token. It is also known as the building block of Java Programs.
                       ♦ Identifiers are user-defined names required to name a class, variables or a method.
                       ♦ Values that are stored in the variables are known as literals.
                       ♦ Punctuators are the special characters that have some special jobs.
                       ♦ Separators are special characters in Java, which are used to separate the variable or the character.
                       ♦ Operators use operands to perform mathematical and non-mathematical operations to give some results.
                       ♦ An escape sequence is a non-graphical character preceded by a backslash (\) having a special meaning for the compiler.
                       ♦ There are two different types of data: primitive and non-primitive.
                       ♦ In Java, there are eight different types of primitive data and four types of non-primitive data.
                       ♦ Arithmetic expressions contain variables, constants and arithmetic operators and are used to do calculations.
                       ♦ The process of changing the value of one type to another type is known as type conversion or type casting. There are two
                      different types of conversions: implicit and explicit.
                       ♦ The wrapper class is used to convert the primitive data type to its object and vice versa. Each primitive data type has a wrapper
                      class of its own.





                                                              MIND DRILL





                      Solved Questions




                 A.  Tick ( ) the correct option.
                    1.  What is a named memory location where a value is being stored?
                       a.  Separator                                   b.  Variable
                       c.  Data type                                   d.  Sum
                    2.  int a=5;
                       What is “a” in the above code?
                       a.  Punctuator                                  b.  String
                       c.  Identifier                                  d.  Literal
                    3.  What type of operator "?:" is?
                       a.  Shift                                       b.  Bitwise
                       c.  Logical                                     d.  Ternary

                    4.  What is the use of "\n"?
                       a.  Inserts a carriage return                   b.  Inserts a vertical tab
                       c.  Inserts a new line                          d.  Inserts a backspcae



                                                                      Primitive Values, Wrapper Classes, Types and Casting  145
   142   143   144   145   146   147   148   149   150   151   152