Wednesday 27 February 2013

Class 9 Revision

Jumping statement :
i) break : This statement is used to transfer the execution flow outside the loop body.
int x=5,i=1;
while(i<=10)
{
System.out.println(i);
i++;
 if (i==x)
break;
}
The output will be:
1
2
3
4

ii ) continue :This statement changes the flow of execution to stop the current iteration and moves to the next iteration.

int x=5,i=0;
while(i<=10)
{
++i ;
 if (i==x)
continue;

else
System.out.println(i);

}

The output will be:1
2
3
4
6
7
8
9
10
11Java Expressions :
i)  

x3+y2  
Math.pow(x,3) + Math.pow(y,2)
 Output :i ) a - (b++) *  (-- c) if a=2, b=3 and c= 9

ans = - 22
Comments :
It is ignored by the compiler, it is used to state the purpose of the instructions in the program.
 // for single line comment.
/*       */  for multiple line comment.
Escape Sequence :
Non printable characters.
\a bell
\b backspace
\f form feed
\r carriage return
\v vertical tab
\t horizontzl tab
\n new line

Data types:
i) Primitive data type: byte,short,int, long,float, double,, char, boolean
ii ) Reference data type: arrays,classes

Thursday 21 February 2013

Class X-Sec A

Chap # 1:
1.     What is a byte code?
2.     What is JDK?
3.     Explain : Java Virtual Machine.
4.     What do you mean by source code?
5.     Explain the importance of import statement.
6.     What is a syntax error? Give one example.
7.     What is a logical error? Give one example
8.     What is a runtime error? Give one example
Chap # 2:
1.     What is an object?
2.     Define a class.
3.     Differentiate between java byte code and machine language code.
4.     Why compiled java code run on most computers?
5.     What is a java package?
6.     Name any 3 OOP’S principles.
7.     Name two types of java programs.
8.     Mention different types of  giving comment in the program.

Chap # 3:
1.     Define : Unicode
2.     Name any 4 tokens.
3.     Define : data type.What are its types?
4.     What is a variable?
5.     What does the keyword ‘final’ mean?
6.     What is type casting? What is the other name for type casting?
7.     What is type conversion? What is the other name given to it?
8.     What is the difference between / and % ?
9.     What are the logical operators?
10.  What are the relational operators?
11.  What is the other name for conditional operator?
12. Differentiate : = and ==
13.Find the output :
int p=5;
d=++p + 5;
14.  a=48, find
a=a++ + ++a;
15. If m=12, find
n=m++ * 5 + --m;
16.  Write the java expression for the following :
(a2+b2)/ab
17. Which keyword is used to create an instance of a class?
 

Wednesday 20 February 2013

Class X -String

Points to remember : (Refer the String post)
1.  ASCII codes :
      A - Z   = 65 - 90
      a - z    = 97 - 122
The difference between a capital and its equivalent small letter is 32.
2. To input a character:
e.g :
char x =  (char)System.in.read( );
3. The difference between next() and nextLine( ) is
next( ) used to input a string without the space whereas
nextLine( ) used to input a line of text.
4. Difference between String and StringBuffer:
String : immutable i.e the characters that the string contains cannot be modified or changed.It has fixed length.
StringBuffer : mutable i.e the string can be changed. Flexible length.

Both are defined in java.lang, so it is available automatically.

5. Exception : unexpected situation encountered by the program.
throws: keyword to inform that an error has occured.
6. String array
 String name[] = new String[10];
10 is not the size of the string , it is the size of the array.
7. Static variable : It is also called class variable. A data member which is declared for a class, ans all the objects share this data member.
   Static method : function which uses static keyword as a modifier.
8. Group of logically related classes together are called Package.

Arrange the names in ascending order:

class sort
{
public static void main()
{
String name[]={........};------Assign names.
int l=name.length;------length of the array not string
int i,j;
String temp=" ";
for(i=0;i< l-1; i++)
{
for(j=0;j< l-i-1; j++)
{
if(name[j].compareTo(name[j+1])>0) ---comparing strings
  {
    temp=name[j];
    name[j]=name[j+1];
    name[j+1]=temp;
   }
  }
}
for(i=0;i<l;i++)
System.out.println(name[i]);
}
}
}

Binary search :
It is similar to numerical search except few changes. Assume there are 10 names and string n should be searched.
int u=9,l=0,mid=0, flag =-1;
while(l<=u)
{
mid=(l+u)/2;
if (n.compareTo(name[mid])==0)
{
flag=mid;
break;
}
else if  (n.compareTo(name[mid])>0)
{
l=mid+1;
}
else if (n.compareTo(name[mid])<0)
{
u=mid - 1;
}
}
if(flag== -1)
System.out.print("Not found in the list");
else
System.out.print("Name"+n+"is at"+flag+"index");
}

Tuesday 19 February 2013

Class X - Arrays

Points to remember:(Refer the class x array post)
1. An array is a collection of values of same data type that are refered by one name.
2. Array subscript begins from 0.
3. Method to receive an array
   example :     int get(int a[])
Section A
1. What will be the output:
public static void main( )
{
    int a[]={5,10,15,20,25};
   int i,j,k=1;
   int m;
   i=++a[1];
   j=a[2]++;
   m=a[i++];
  System.out.println(i);
  System.out.println(j);
  System.out.println(m);
}
2.
public static void main( )
{
int b[]={2,4,6,8};
int i,s;
for(i=o;i<=1;i++)
{
s=b[i]+b[3-i];
System.out.println(s);
}
3. Differentiate linear search and binary search.
Section B
1. Write a program to assign the following values in an array and arrange them in ascending order using bubble sort.
5, 3, 8 ,12, 1, 2,23,16,30

2. Write a program to input a single subscripted variable a[] of 40 integers. Arrange them in descending order using selection sort method.

3. Write a function int search( ) which takes an integer array x[] of 10 integers( which is already arranged in ascending order), and an integer val as a parameters.Search val from the array using binary search and return 1 if val is found else return -1.



Class 9- Final Exam

Computer portion doesnot include nested loops for the final exam.
Here are some programs to practice.
1. Convert the following for loop into equivalent do while loop.             
     inta,b;
for(a=40,b=20;b>=15;b=b-5)
a=a+3;
2.  What is the name of the following loop and write its function?                 
 for(; ;)
3. Predict the output for the following code segment:                                
     int a=0,i=4;
while(i<10)
{
    a= ++ i – i*2;
}
System.out.print(“a=” +a +”i=” +i);
4Find the erors if any in the program:                                                        
  int x=100, y=65;
do
{
       s=s+x;
       x=x+5;
}while(x<10);
System.out.print(s);
system.out.print(x+y);

Section B
1.     Write a program to enter a number and display the factorial of  that number.
Example :  Factorial of 5 is 1x2x3x4x5                                 
Use for loop.     

2.  Input a number and print it after reversing it. Use while loop.       
     Example :
Input : 1479
Output : 9741
3. Write a program to input a number and print the multiplication table  of that number from 1 to 10.                                                           
   Example: if the input is 4 then the output should be
1 x 4 =4
2 x 4 = 8
.
.
10 x 4 = 40
4. Write a program to enter a number and display the sum of the digits of the number.      Use do – while.            
     Example :
Input :  346
Output : 13

5.
Write a program to print the even numbers from 15 to 50. Use do while loop.   



                             

Monday 18 February 2013

Constructor

Points to remember:
1. A constructor is special function of a class, with the same name as of the class name.
2. Constructor never returns a value, not even void.
3. A constructor can not be called or invoked like a function.
4. More than one constructor is called constructor overloading.

Section B

1. Make a class factorial whose members are as given:
factorial ( ) - default constructor to assign 1 to f.
factorial(int n) - a parameterized constructor to assign num=n.
int get() - to find and return the factorial of num.
Write a program to input a number and print its factorial.

2. A class Reverse is defined as follows:
Data members:long integer num
Member functions :
Reverse(long n) : to store value of variable n to num
long findReverse( ) - find and return reverse of the number present in num.
Write a program to input number and by invoking suitable funtion print the original and reverse number.

Friday 15 February 2013

Class X - Method

Points to remember:
1. Two ways of invoking functions: call by value, call by reference.
2. Function overloading: More than one function with the same name but different arguments or data types.
3. A function returns only one value at a time.

Section A
1. What is function prototype?
2. What is function signature?
3.Differentiate : Actual and Formal parameters.
4. Explain :
     i. Calling the funtion by value.
    ii. Calling the function by reference.
5.Explain Pure and Impure functions with examples.
6. What is the function of  'this'  keyword.
7. Give the prototype of a function check which receives a character ch and an integer n and returns true or false.

Section B
1. Design a class overloadCompare to do the following:

void compare (int,int) - compare and print the biggest of  2 integers.
void compare(char,char) - compare the numeric values of two characters and print the charecter with higher numeric value.
compare(String,String)- compare the length of 2 strings and print the longer of the two.

2. Write a menu driven program using a function area( ) to compute the following:
area of square = side x side
area of circle = 3.14 x r x r
area of rectangle = l x b
3. Define a function primeNum (int n) which returns 1 if n is prime otherwise returns 0.
4. Define a class equation to print the results of the following equation with the help of the functions:
n ! /  r ! * (n-r)!

Wednesday 13 February 2013

Mrs.Jayanthi Srinivasalu









We do not choose to be born. We do not choose
our parents. We do not choose to die; nor do
we choose the time and conditions of our death.
But within the realm of choicelessness, we do
choose how we live.
Joseph Epstein

I can say for sure you lived well.
Where do I start ... talented craft teacher, great cook, lovely friend,wonderful colleague , asset to the institution list is endless.The programs in the school and The Pakenham Walsh House sports tent will not be same again.. Thank You Jayanthi for all you have done to us.

I read this somewhere......

God saw you getting tired
And a cure was not meant to be.
So he put his arms around you
And whispered 'Come to Me'.
With tearful eyes we watched you …

Rest In Peace

Thursday 7 February 2013

Loop 2

Points  to  remember :
1. for( i =1,x=1;i<=5;x++,i++)
 two variables can be assigned initial values. Both get incremented simultaneously.But the loop will go on till i is less than or equal to 5.
2.  When you have nested loops, the inner loop gets executed completely,then it goes to outer loop.
3. A compund statement is a set of two or more statements.It is also caleed a block.                                          [ICSE 2005]
4. for loop is fixed iterative type, where the loop repeat for a definite number of times. while and do - while varying iterative type , where the statements are repeated till the condition is true.
5.
1. Write a program to display the following :
a)
1
1  2
1  2  3
1  2  3  4
1  2  3  4  5

b)
1
2  2
3  3  3
4  4  4  4
5  5  5  5  5

c)
5  4  3  2  1
5  4  3  2
5  4  3
5  4
5

2. Write a program to input a number and check whether it is a Special number or not. A number is said to be Special number, if the sum of the factorial of each digit of the number is same as the original number.                 [ICSE 2011]
145= 1 ! + 4! + 5!
      =1+24+120
       =145

3. Write a program to input a number and check whether it is a Automorphic number or not. A number is said to Automorphic if the original number is present on the right of the square of the number.
 5 is Automorphic = 25
25 is Automorphic =625

4. A number is said to be Neon , if sum of all the digits of square of a number is equal to the entered number.

9 = square is 81
   = 8 +1
   = 9

Monday 4 February 2013

Loop - class 9

Points to remember :
1. break statement is used to break the loop.
2. continue sends the control to the update expression.
3. for loop is used for fixed iterations.That is where you know the final limit.
4. In while loop, condition is tested before execution.
5. The do while loop executes the statements atleast once even if the condition is false.
6. Infinite loop : control does not reach the test condition.
7. Empty loop : loop does not contain any statement in the body.


1. What will be the output for the following programs:
i)
            for(a=0;a<30;a++)
           {
                   if(a==5)
                   break;
                   System.out.print(+a);
          }

ii)
      for(x=1;x<=5;x++)
      {
           if(x==2)
          continue;
          if(x==4)
          continue;
System.out.println(x);
      }
iv)
        int x=0;
       while(x<=10)
        {
               x++;
             if(x==4)
              break;
             System.out.println(x);
        }
2. Differentiate : while and do while.
3.Write a program to enter a number and print the sum of odd numbers and even numbers for the first n natural numbers.                                                                     [ICSE]
4.
      i)         12+22+32+42+…………+n2
      ii)     x2/2+x3/3+………xn/n

1. Fibonacci series:
 0,1,1,2,3,5,8.............................
2. Prime number:
    The divisors are one and the number itself.
    e.g : 5 : divisors 1 and 5
3. Perfect number :
     The sum of the divisors(excluding the number) equal to the number itself.
    e.g : 6
       divisors are 1+2+3=6
4. Armstrong number:
    e.g :
         153=13+53+33
               =1+125+27
               =153
5. Palindrome number:
  e.g:
        272: reverse the number 272.