Wednesday, 25 July 2018

Java

There are some very good questions from this chapter.But almost all of them are direct.
Types of Java :
  • Stand alone : A java program developed by the user.
  • Internet applets : Java programs which are executed using web browser.
Basic features of Java :
  • Object oriented programming
  • both complied and intepreted
  • platform independent
  • No memory pointers like in c++
  • No preprocessor
  • Automatic memory management
  • Built in networking
  • Dynamic binding
  • Open product (i.e) freely available
  • Multithreaded : Perform multiple tasks simultaneously.
 The conversion of high level language(source code) to machine level language can be done in two ways.
Interpreter converts  line by line.
Whereas compiler converts all at once.

Byte code:
The java programs are converted to a code called byte code.It is independent of the machine on which the program is to run.Java virtual machine (JVM)is an interpreter which translates byte code into machine code.
Java Source code--->java complier--->byte code--->JVM

Java code can run on many computers coz  java interpreters(JVM) exist for most operating systems.

Comments in Java :
  • Single line comment : //
  • Multi line comment : /*                        */
Errors :
  • Syntax : e.g semicolon missing,bracket missing,variable not declared.
  • Run time :(e. g)dividing by zero
  • Logic : The program does not produce the answer we want.

class 9 Java introduction

Creating a set of instructions to make the computer to do something is no Rocket Science. Just a bit of logic, bit of syntax, bit of patience, bit of interest and bit of concentration in the class are all you need to learn the language.

Programming ,  most of the times involve 4 steps:
  1. Declaration
  2. Assign / Input
  3. Calculation (if necessary)
  4. Print
Example 1 :

Write a program to print your name and school name.

class prog1
{
  public static void main( )
  {
      System.out.print("Bishop");
      System.out.print("Cottons");
   }
}
   
   This is the basic structure of the program. You might have noticed that the program did not use all the above 4 steps. 

  We don't have to use all the steps in all the programs. 
The output is going to be :
BishopCottons

System.out.print( ) displays anything written inside the brackets.

In case if I don't want the answer in single line , I have to use

System.out.println( ).

In case if I want the answer in a single line but separated by a space or a comma then,

System.out.print("Bishop" + "  " + "Cottons" ).

The answer will be Bishop  Cottons

In the print statement, the + symbol is not an addition symbol rather it combines two items, that is Bishop and space and also space and Cottons. So there are 3 items Bishop, space , Cottons.

So if I make a small change in my program the answers will be in two different lines.
    
class prog1
{
  public static void main( )
  {
      System.out.println("Kavitha");
      System.out.print("Cottons");
   }
}


 Example 2 :

Write a program to assign two values and print its sum.

class prog2
{
  public static void main( )
  {
      int a, b,c;  -------------------------------------- Step 1
      a=5;         ---------------------------------------Step 2
      b=30;      ----------------------------------------Step 2
      c=a+b;    --------------------------------------- Step 3
      System.out.print(c);  ------------------------- Step 4
     
   }
}

The output will be 35

Step 1 : Declaration.

           Mention the data types of the variables involved.
Step 2: Assign

           Put some values in your variables.
Step 3 : Calculate

           Add the values and store it in the new variable. Remember variable = constant not the other way round.

Step  4 : Print

               Display the answer. you can also write
         System.out.print("Sum= " + c);

The answer will be Sum = 35. This is the good way of displaying the answer with a message.

Steps 1 and 2 can be combined to form a single statement.

  int a = 5, b=30, c;

Input Methods

   We are going to learn 2 input methods .

  • Blue J
  • Scanner


 Blue J Method

class prog3
{
  public static void main( int a, int b ) ----- Accepting values                                                                              from the user
  {
      int c;
      c=a+b;
      System.out.print("Sum = " + c);
   }
}

Even though both a and b are of same data type ,  it should be mentioned twice and should be separated by comma(,).

public static void main( int a, b ) ------ Wrong


 See you in the next post.

Tuesday, 24 July 2018

Class 7 - Revision

QBASIC
Revision :

There are 3 types of character sets : 
Alphabets
Numbers
Special Characters.

Operators:
Arithmetical Operators
Relational Operators
Logical Operators

In arithmetical operators learn the various symbols you use in QBASIC. Because some symbols in computers are different from symbols in Maths like multiplication, division.
You should be able to write the corresponding QBASIC expression for the given Mathematical expression.

e.g:

         4ABC = 4 *A* B*C

In relational operators , learn all the symbols. You should be knowing it gives the answer either in True or False.

e.g:

      X = 5 , Y =8 
(X > 5) will give False 

(Y < >10) will give True

In Logical Operators you should be familiar with the truth tables.

A = 3 , B= 6 and C=10

(A > B) AND (C < 100)
A>B is false so the answer is false.

You should also know how to convert a given instruction into a QBASIC instruction.

e.g:

The sum of a and b  is less than the product of a and b.
          (a + b) < ( a *b)

In the second unit Constants and Variables , 

You should be familiar with the rules for writing the variables and constants.

Numeric variable will store Numeric Constant.
Alphanumeric variable will store alphanumeric Constant.

You cannot mix up the constants and variables.
                                 Numeric variable = Numeric constant
                                             E = 20
                         Alphanumeric variable = Alphanumeric constant
                                           G$ = "Class"

Remember variable on the left hand side and constant on the right hand side.
                               A = 100
In alphanumeric variable , there should be a $ in the end.
Alphanumeric constant should be within double quotation.

                               B$ = " Computer Science"
                               D1$ = " Bond 007"
You should know how to write valid valid(correct) variables for the given constans.

e.g:

                      ------------ = " Rain"
              Here write any valid alphanumeric variable. Because on the right hand side "Rain" is the alphanumeric constant. (Remember double quotation means alphanumeric )
                      W$ = "Rain"

                     --------------- = 7.8
            
              Here write any valid numeric variable. Because on the right hand side 7.8 is the  numeric constant. 
                     
                        B = 7.8

Wednesday, 18 July 2018

Class 7 - QBASIC Expressions


Java Revision 2

Class 8 and 9 

Loading Java

Tuesday, 17 July 2018

Java Revision 1

Class 8 and 9

Monday, 16 July 2018

Class 7 - QBASIC


Loading QBASIC

Class 7 - Variables and Constants

Class 7 Variables



Saturday, 7 July 2018

Class 7 - Fundamentals of QBASIC QUIZ