Page 6 - CA_Blue( J )_Class9
P. 6

INSIDE THE SERIES



                                                  Learning Resources





                                    Learning Objectives


                               2.1 Class in Java         2.2 Object             2.3 Properties of Class and Object

                                                                  radian = (22.0/7.0*30)/180.0 = 0.5238
                            Learning Objectives: This section describes the objective of the chapter.
                                                                  Example of Math.sin() :   double r = Math.sin(radian);    // Output : 0.5
                                                                  Example of Math.cos():   double r = Math.cos(radian);   // Output : 0.865
                                                                  Example of Math.tan():   double r = Math.tan(radian);   // Output : 0.5776
                               Definition                          Some More Programs               Century   #Coding & Computational Thinking
                                                                                                     21 st
                                                                                                     Skills
                  Exception: A situation in which the execution    Program 1  Write a program to find the increase in kinetic energy of a body of mass 500 g, when its
                                                                          velocity increases from x m/s to y m/s.
                  of a program stops abnormally.                    1  import java.util.*;
                                                                    2  class kinetic_energy
                                                                    3      {
                                                                    4          public static void main ()
                  Definition: This section provides a             Some More Programs: This section contains
                                                                               {
                                                                    5
                                                                                   Scanner sc= new Scanner (System.in);
                 definition to the important terms in               6 7 additional programs related to the chapter.
                                                                                   double massg, masskg, v1, v2, ke;
                              the chapter.                          8              System.out.println("Enter v1 : ");
                                                                    9              v1=sc.nextDouble();
                                                                   10              System.out.println("Enter v2 : ");
                                                                   11              v2=sc.nextDouble();
                                                                   12              massg= 500;
                                   Let’s Revisit                   13              masskg= 500.0/1000.0;
                                                                                   ke=1.0/2.0 * masskg * (Math.pow(v2,2) - Math.pow(v1,2));
                                                                   14
                                                                   15              System.out.println("The increase in Kinetic energy is: "+ke + "J");
                                                                               }
                                                                   16
                         Initialisation means to assign an initial value to a variable before using the variable in the program.
                                                                   17      }
                         We can take values using parameters passed to methods.
                                                                  You will get the following output:
                         The Scanner class is a predefined class in Java.
                    Let's Revisit: This section provides a summary of the chapter for quick recapitulation.




                                                                   146  Touchpad Computer Applications-IX
                         GLOSSARY                                               MOST COMMON MISTAKES IN

                                                     21 st   #Digital Literacy   PROGRAMMING
                                                    Century
                                                    Skills  #Communication
                       1.   Access Specifier: Access modifiers are keywords in object-oriented languages that set the accessibility of
                       classes, methods, and other members.                   1.  Accessing non-static members from static methods: It is a very common mistake to try and access a
                       2.   Array: It is a collection of data items that are all of the same type. Each item's position in an array is   non-static member from a static method and it happens very often in the main() method.
                       uniquely designated by an integer.                     Solution:  While creating a method always be mindful of the purpose and scope of the method. Always
                       3.   Assignment Sign: It is denoted by a ‘=’ sign. It is used to assign a value on the right to the variable on the   remember that we can access an instance variable by an object of its class only and static methods can
                       left.                                                  only access static members of the class.
                       4.   Boolean Literal: It is a special literal that holds constant value as true or false.     2.  Missing closing curly braces: Beginner programmers often forget to close the braces. It issues a syntax
                       5.   Bytecode: It is an intermediate binary form of Java source code that is obtained after the compilation of   error.
                       the program.                                           Solution: The easiest solution to this problem is to insert both the opening and the closing brace at the
                       6.   Break: A statement used to exit a loop or a switch statement.  same time and writing the code within these braces.
                       7.   Buffer: It is a reserve space in memory used for temporary storage. It is also called cache memory.  Most Common Mistakes in Programming:
                                                                            3.  Missing break in switch case construct: This is a major problem and can cause major trouble. This

                       8.   Compiler: A software that is used to convert high-level languages to machine language. It converts an   error often escapes the programmer’s eyes because it never causes a compiler error.
                       entire program at once.                          This section contains an overview of some
                                                                              Solution:  To avoid this error, perform a dry run in your mind while coding each case. This will help you
                       9.   Continue: It is a statement used to skip the current iteration in a loop and move on to the next step.  to get a solid grasp of the output and the working of the programming construct.
                       Glossary: This section contains
                      10.   Data Abstraction: It is a feature of OOP that refers to the act of presenting the essential features without   of the common mistakes that programmers
                                                                            4.  Confusing assignment with comparison (= and ==): This can cause a compiler error and issue logical

                       including the background data.                         and runtime errors based on the program.
                      definition of important IT terms.                      often make while programming.
                      11.   Data Hiding: It refers to the act of limiting the access to data directly outside the class premises, even if the
                                                                              Solution: Note that ‘=’ is an assignment operator and ‘==’ is a relational operator and they are different
                       data is present in the same program.
                      12.   Debugging: It is an act of removing errors or bugs from a program.  from each other. Hence, the best way to avoid this issue is to get a clear grasp of the programming
                                                                              concept and the difference between these operators. This will always keep you on the lookout for
                      13.   Encapsulation: It refers to the process of wrapping the data and methods together in a single unit.  these kinds of errors and help you avoid them.
                      14.   Explicit Conversion: It refers to the process of converting one data type to another according to the user’s      5.  Using less restrictive access modifiers: This error can affect the working of a program and cause
                       wishes.
                                                                              serious accessibility problems.
                      15.   Expression: It is a combination of two or more than two operands/variable and arithmetic operators that
                       makes sense.                                           Solution: Access specifiers are important to a program and a key concept in java programming. To
                                                                              avoid these issues, you must be mindful of the usage of the access specifiers in your program and
                      16.   Floating Literal: A real number is considered a floating literal if it includes a decimal point.
                                                                              retain a solid grasp of the concept.
                      17.   Identifier: It is used to identify the key elements of a program like class name, object name, methods,
                       variable name, etc.                                    6.  Forgetting to free up resources: This is an aspect that almost all the beginners tend to miss. Though it
                                                                              is easy to miss, it can lead to extensive memory and resource usage.
                      18.   Implicit Conversion:  It refers to  the process of converting one  data type to  another  without  user
                       interference.                                          Solution: This is a concept that programmers learn with time. But, you can pick up on it quickly if you
                      19.   Impure Function: These are functions that may or may not return any value but they can change the state   are mindful of the amount of resources you are using and freeing it up while finishing the program.
                       of an object.                                          7.  Logic Errors: These are vital errors that can be very hard to spot. These errors affect the working of a
                      20.   Inheritance: It is a feature of OOP that allows one class to acquire the properties of another class.  program and its outcome.
                      21.   Instance Variable: It is a variable that is defined within a class outside any member function and provides   Solution: To avoid such errors, always check the working of your program and determine if there is a
                       a separate copy of itself for each object of the class.  flaw in the idea you had for the program.
                     310  Touchpad Computer Applications-IX
                                                                           312  Touchpad Computer Applications-IX
   1   2   3   4   5   6   7   8   9   10   11