Thursday 18 July 2013

SHUTDOWN your machine using JAVA.....


copy and paste .....see the magic in xp....after running it wait for 2 mins..i will explain it in my class...for any problem call me 9434226403...

import java.io.*;
class csk
{
  public static void main(String ags[])throws IOException
  {
     Runtime r=Runtime.getRuntime();
      r.exec("shutdown -s");
  }
}

Prime no in an Efficient Way for ICSE students.....

import java.io.*;
class csk123
{
 public static void main(String args[]) throws IOException
 {
    int n,i;
    DataInputStream in=new DataInputStream(System.in);

    System.out.print("Enter a no:");
    n=Integer.parseInt(in.readLine());


    for(i=2;i<=n/2;i++)
     {
      if(n%i==0)
       break;     
     }

       if(i==(n/2+1))
        System.out.print("Prime");
       else
        System.out.print("not prime");

 }
}


copy and paste ......this program run very much faster than older one, bcoz the loop execute less number of times than the older prime program(from 2 to n/2 instead of 1 to n), sometimes  loop does not execute upto n/2 bcoz of break statement...I will discuss the logic in the class....

Saturday 13 July 2013

important theory questions with answers...(1st set)


Q1. Types of comments

Single Line-
//

Multi Line-
/* …

 …
              */

Documentation Comments – Which are displayed by the IDE. The are multiline
comments only given immediately before the function header.

Q2. What are tokens? Name the 5 types of tokens available in Java with an example each. 
The smallest individual unit in a program is known as a token. The five types of tokens
are- : 
a) Keywords:-  public, static, void, import etc. (Java’s own terms)
b) Identifiers:- (variables) alphabets, digits, under score, dollar sign etc.     


c) Literals:- (Constants) integer literals, floating literals, boolean literals, character literals, string
literal, the null literal. 

d) Punctuators (separators):- ()
{}
[]
;

 
e) Operators  =
 +
 -
 <
 >
Q3. What are escape sequences? Give any 5 escape sequences?

Codes for non-graphic or some special characters. 

‘\t’, ‘\n’, ‘\b’, ‘\\’, ‘\’’, ‘\”’, ‘\?’

Q4. ASCII codes?

A-Z = 65-90, a-z=97-122, ‘0’-‘9’=48-57


Q5. Prepare a chart showing all the data types with their size and range. 

See table with answer 12.

Q6. How can we declare a variable whose value cannot be changed in Java? 

If we write the final keyword before the variable name, then the value of that variable
cannot be changed later in the program. Any attempt of doing so will produce a compilation
error.
final int a=5;

Q7. Give the value (with reason) that the variable on the left hand side will hold in the following
statements
 
float a=(float)(21/2); 
int b=5 * 3/4 + 4/3 + 6; 
int c=100 + 10>10?10:20; 
float d= '1'+ '2'; 
int e= 20%7 / 2*3;


a) float a= (float) (21/2);
Output-: First integer division takes place= (float)(10). Then the answer is converted to floating type=10.0.

b) int b= 5*3/4+4/3+6; 
Output-:First multiplication takes place=15/4+4/3+6. Then
division=3+1+6.At last addition= 10. 

c) int c= 100+10>10?10:20; Output-:First addition takes place=110>10?10:20.Then ternary
operator works and returns the answer= 10.

d) float d= ‘1’+’2’;

Output-:The ASCII codes of these characters are added(49+50)
and converted into floating type=99.0.

e) int e= 20%7/2*3; 
Output-:First mod (6/2*3), then division(3*3) and at last
multiplication= 9. 

Q8.  Define (i)Precedence and Associativity  (ii) Mixed/Fixed(pure expr.) mode?
(i)
Precedence : Order of evaluation
(ii)
Associativity : Order of evaluation when precedence is the same.
(iii)
Mixed Mode or Impure Expressions – When operands are of different data types. 
(iv)
Fixed mode or pure expressions – When operands are of the same data type.

run any exe file using java code ...if u face any problem contact me 9434226403

 //this code will open notepad.exe ...if u face any problem contact 9434226403

 
import java.io.*;
class csk

{
  public static void main(String args[])throws IOException
  {
   
 Runtime r=Runtime.getRuntime();
  r.exec("notepad.exe");

  }
}

Friday 12 July 2013

Important one liners....

Object An entity having specific characteristics(variables) and behavior(Methods)                                                                                        

Abstraction Hiding unnecessary details and presenting the required ones.

Encapsulation Binding and wrapping up of methods and data members.

Class Representation for a set of objects having common behaviour and characteristics.

Byte code The java byte code is a machine language instruction set. The byte code is independent of the computer system it has to run upon.

Native Executable Code A machine code program which can run on a specific platform
(hardware/ software) only.

JVM Set of Java programs (interpreter compiler etc.) which converts source code to byte code and is also responsible for executing the program. (JRE)

Applet Internet Applets are small programs that are embedded in web pages and are run on the viewers’ machine (which are meant to run on the internet browser)

Stand Alone Applications – Meant to run on an independent machine.

Inheritance When a class acquires properties of another class (may add a few of its own).

Polymorphism Behaving differently under different situations. Having one name but many different shapes.

Object Code A machine language conversion of the source code. 2 types – Applet, Stand alone applications.

Recursion When a function calls itself
 public void abc()
 {
 abc();
 }

WORA Write Once, Run Anywhere (+ do a few more properties)

IDE Integrated development Environment (E.g. Blue J) – where we can type, edit, debug, run, organize etc. java programs.

Compiler Which converts the all the source code to machine code before execution. (whole program)

Interpreter Which converts and executes source code line by line.

API Applications Programming Interface (Java Libraries) (inbuilt feature/packages)

JRE Java Runtime Environment – What JVM creates to run a Java program.

Type Casting Writing a data type in () before a value, variable or an
expression to change its type temporarily.
Sop((char)65)
Used in explicit type conversion



  • Making JAVA a fun to learn experience for the school students by striving  to build clear fundamentals of every concepts and helping students to develop their ability to reason and logically analyze any given programs  .                                                                                             
  • Important notes and programs along with their solutions are also provided for aiding the students who are preparing for their board examinations of Class 10 (ICSE) as well as Class 12 (ISC) .                  
  • Monthly sample practice questions are also posted, so that students make maximum benefit .                              
  • Also, I will be posting Complete Sample Question Papers / Suggestions for upcoming board exams for both ICSE and ISC students .                                                                                                                
  • Previous years ICSE and ISC question papers will also be uploaded soon .                                             
  • If you have any question or want a program to be done, then you can contact us and I will try our best to answer you.                                                   

For those living in Asansol (West Bengal, India), they can contact the teacher behind this initiative for tuition related queries.  Mr. C.S.Kundu 9434226403

programs


BUZZ numbers

Buzz numbers are the numbers when we  divide the number with 7 the number should totally divisible with 7 or the reminder should come 7 of the number when we divide it with 7
example  :-49,56

import java.io.*;
class buzz
{
public static void main(String args[]) throws IOException
{
  int n;
DataInputStream in=new DataInputStream(System.in);

System.out.print("Enter a no");
n=Integer.parseInt(in.readLine());
if(n%10==7||n%7==0)
     System.out.println("buzz");
else
     System.out.println("not");
}
}