Sei sulla pagina 1di 7

.

Class file : Its a file generated by compiler

It contains a specific code termed as byte code

++Components of a byte code :


---------------------------------

a)name of your source file ( java file )

b)It contains the output to be printed

c)Line Number Table ,it contains the information

of the classes required to run the application

Even in the case of java we can find classes

a)Predefined -- System , String ,PrintStream

b)User Defined

++Currently we are deisghing desktop application

1)Console Application : Here we are using

command prompt

We require output stream

Standard Input --- System.in

Standard Output ---- System.out --- Its behaving

like output stream ,this stream created by

JVM

Application2 ) We want to construct a

calculator , we want to perform some arithmetic

Operations

+ ===> Operator ----> Operands ---> variables

2 + 4

variable1 --- 2 --- integer

variable2 --- 4 --- integer

Variable contains

a)Name

b)Data Type
Student Information

Student Id --- numeric --- integer

Student Marks --- numeric --- integer

Student Gender --- Male --- M


charcater
FeMale --- F

Student Name --- a collection of characters

--- string

How to take a variable

datatype VariableName;

int variable1;

int variable2;

variable1 = 10;

variable2 = 20;

variable1+variable2 ----> we have to take one

more variable

ex: addition

2)Windows Application

Desighn Phase --- Java Code / Source Code

Compilation Phase --- Byte Code

Execution Phase ---- Executable Code /

Machine Understandable Code

Executable code generated by JVM

Run time Library :


//////////////////

C Language ---- Header Files --- stdio.h

C++ Language --- Header Files --- iostream.h

Java Language ---- Packages ---> java.lang

java.io

java.util
WHAT DOES A PACKAGE CONTAIN :
------------------------------

In java we are finding classes ---> Predefined

Classes

System ====> Predefined Class ---> java.lang

String ====> ,, ,, ---> java.lang

PrintStream ===> ,, ,, ---> java.io

In java how to use run time Library

We are using import ,where by we specify

the package name

Synatx

import packagename.*;

* ---> All the classes present in that package

import java.lang.*;

Here * is called the wild card

++Supose we want to use a specific class

we can use the below syntax

import packagename.classname;

ex:

import java.lang.System;

import java.lang.Math;

++Here Math is a class , predefined class

++It contains a collection of methods

ex:

sqrt() --- to calculate square root of a number

cbrt() ---- to calculate cube root of a number

pow() --- to calculate power of a number

import java.lang.Math;

class App4
{
public static void main(String args[])
{

int number1;
int number2;

number1 = 25;

number2 = 27;

System.out.println(Math.sqrt(number1));
System.out.println(Math.cbrt(number2));

Structure Of A Java Application :


/////////////////////////////////

#include<stdio.h>

void main()
{

A collection of instructions

import packagename.classname; ===> Import Section

It means we are importing a package ,

In java we can import multiple packages coming

Under The Import Section

++We have to define / create the class ===>

Clas Definition

++Apart from that we have to place comments

In C & C++ we have 2 types of

comments

a)Single Line Comment

ex:

// this is a single line comment

b)Multi Line Comment

/*

this is a
multi line

comment */

//A program to calculate total marks of student

class StudentDemo
{

public static void main(String args[])


{

int marks1;
int marks2;
int marks3;

marks1 = 90;

marks2 = 80;

marks3 = 70;

/*

below we are calculating

the aggregate of student marks

*/

int totalMarks = marks1+marks2+marks3;

System.out.println("The total marks is "+totalMarks);

float percentage = totalMarks/3;

System.out.println("The percentage is "+percentage);

++In java we have one more category of

comment ,its called as the document comment

( documentation comment )

/**
* this is a
* documentation comment
*
*/

Activities :
------------
Activity2 ) Create an application to perform below conversions

--- kilo meters to meters

--- dollarls to indian rupees

--- feets to inches

++We are taking documentation comments at multiple places

++Mostly we place it at top of the application even before

import section

Application --- Created by Some Developer --- Author

Creation Date --- on which the application

was created

version --- the version is starting from 1.0

++We can place all this information in documentation comments

/**
*@author steve
*@version 1.0
*
*/

++This is coming under documentation section

Under the structore

a)Documentation Section

b)Import Section

c)Definition of the class

d)package section

Potrebbero piacerti anche