Page 151 - Computer science 868 Class 12
P. 151

public static void main()
                        {
                            int a, b=0;
                            a = 2;
                            Integer c = new Integer(a);
                            b = a;
                            System.out.println("Autoboxing = "+c);
                            System.out.println("Unboxing = "+b);

                        }
                    }
                 Output:
                 Autoboxing: 2
                 Unboxing: 2




                               Let’s Revisit


                       ♦ The different combinations of the characters are used to declare variables, keywords and symbols which are required to
                      write a whole program. These are known as Character Sets of Java.
                       ♦ Any meaningful statement containing identifiers, literals and arithmetical operators that produces a result is called an
                      Arithmetical Expression and when the expression is assigned to a variable, then it is called an Arithmetical Statement.
                       ♦ There are two types of conversions in Java:
                      *  Implicit Conversion that is done automatically
                      *  Explicit Conversion that is done by force
                       ♦ Wrapper classes are used to convert primitive data values into objects and objects to primitive data types.
                       ♦ Autoboxing is a method of converting a primitive value into an object of the corresponding wrapper class.
                       ♦ Unboxing is a method of changing an object of a wrapper class into its corresponding primitive value.







                                                              MIND DRILL



                     Solved Questions


                 A.  Tick ( ) the correct option:
                    1.  Alphabets are a type of ………………… .
                       a.  Unicode Character Set                       b.  Java Syntax
                       c.  Both a and b                                d.  None of these
                    2.  The long data type is a 64-bit integer or equivalent to …………………  .
                       a.  1-bit                                       b.  4-bits
                       c.  32-bits                                     d.  8 bytes
                    3.  Non-primitive data types are also called ………………… .
                       a.  Reference data types                        b.  Composite data types
                       c.  Both a and b                                d.  None of these





                                                                                                                       149
                                                                         Primitive Values, Wrapper Classes, Types and Casting  149
   146   147   148   149   150   151   152   153   154   155   156