Sunday, November 20, 2016

The difference between class and object

“The difference between class and object"

Class
i) A class is a way of binding the data and
associated methods in a single unit.

ii) Whenever we start executing a
program, the class will be loaded into
main memory with the help of
loader subsystem (a part of JVM) only
once.

iii) When the class id defined there is no
memory space for data members
class.


Object

i) Class variable is known as an object
class.

ii) After loading the class into main
memory, objects can be created in n
number.

iii) When an object is created we get the
memory space for data members of the
class.

Features of java

FEATURES OF JAVA:

1. Simple
2. Platform independent
3. Architectural neutral
4. Portable
5. Multi threading
6. Distributed
7. Networked
8. Robust
9. Dynamic
10. Secured
11. High performance
12. Interpreted
13. Object Oriented Programming Language

*********************************************************************************
1. Simple: JAVA is simple because of the following factors:
i. JAVA is free from pointers hence we can achieve less development time and less
execution time [whenever we write a JAVA program we write without pointers and
internally it is converted into the equivalent pointer program].
ii. Rich set of API (application protocol interface) is available to develop any complex
application.
iii. The software JAVA contains a program called garbage collector which is always used to
collect unreferenced (unused) memory location for improving performance of a JAVA
program. [Garbage collector is the system JAVA program which runs in the background
along with regular JAVA program to collect unreferenced memory locations by running
at periodical interval of times for improving performance of JAVA applications.
iv. JAVA contains user friendly syntax’s for developing JAVA applications.


2. Platform Independent:
A program or technology is said to be platform independent if and only if which can run on
all available operating systems.
The languages like C, Cpp are treated as platform dependent languages since these
languages are taking various amount of memory spaces on various operating systems [the
operating system dos understands everything in the form of its native format called Mozart (MZ)
whereas the operating system Unix understands everything in its negative format called
embedded linking format (elf). When we write a C or Cpp program on dos operating and if we
try to transfer that program to Unix operating system, we are unable to execute since the format
of these operating systems are different and more over the C, Cpp software does not contain
any special programs which converts one format of one operating system to another format of
other operating system].
The language like JAVA will have a common data types and the common memory spaces on
all operating systems and the JAVA software contains the special programs which converts the
format of one operating system to another format of other operating system. Hence JAVA
language is treated as platform independent language.

[JAVA language is also treated as server independent language since the server side program
can run on any of the server which is available in the real world (web server or application
server). JAVA can retrieve or store the data in any one of the data base product which is
available in rest world irrespective of their vendors (developers) hence JAVA language is product
independent language.
In order to deal with server side program from the client side, we can use C language client
program, Cpp client program, DOT NET client program, etc. hence JAVA language is a simple,
platform independent, server independent, data base/product independent and language
independent programming language].



3. Architectural Neutral:
A language or technology is said to be
processors in the real world.
The language like JAVA can run on any of the processor irrespective of their
vendor.


4. Portable:
A portable language is one which can run on all operating systems and on all processors
irrespective their architectures
portable languages whereas the language
J2SE (Core JAVA) Notes
architectural neutral which can run on any available
The languages like C, Cpp are treated as architectural dependent
and providers. The languages like C, Cpp are treated as
JAVA is called portable language.



5. Multi Threading:
1. A flow of control is known as
2. A multi threaded program
3. A program is said to be multi threaded program
programs. For each and every sub
flow of controls are executing concurrently. Such
type of applications is kno
4. The languages like C, Cpp are treated as
(STML). SMTL are those in which there exists
5. The languages like JAVA
(MTML). MTML are those in which there exist
6. Whenever we write a
foreground/child thread
7. A foreground thread is one which always executes user defined sub
program there is a possibility of existing n number of
8. A background thread is one which always monitors the status of
and every JAVA program t
9. Hence background thread



6. Distributed:
A service is a said to be a
can be accessed by n number of clients across the globe. In order to develop
applications we must require architecture called
applications we require a technology called
scale organizations.

thread. is one in which there exists multiple flow of controls
if and only of there exists n number of sub
sub-program there exists a separate flow of control
flow of controls is known as
known as multi threading applications.
threads as single threaded modeling languages
single flow of control.
and DOT NET are treated as multi threaded modeling languages
multiple flows of controls
JAVA program there exists by default two threads
and background/main/parent thread.
sub-programs. In a
foreground threads
foreground thread
there exists only one background thread.
will be created first and later foreground thread
distributed service which runs in multiple servers
trusted network architecture. To develop these
J2EE. Distributed applications are prefer



7. Networked:
In real world we have two types of networks. They are
networks.
Un-trusted networks:
A network is said to be
connected non-autonomous architecture
network architecture, we develop
runs on single server and it can be access in limited graces.
applications we may use a technology called
by small scale organization.
Trusted network:
A network is said to be
autonomous architecture. Trusted network
develop distributed applications
and it can be access in unlimited graces.
J2SE (Core JAVA) Notes
un-trusted networks
un-trusted network in which there exists n number of
architecture. Un-trusted network is also known as
centralized applications. A centralized application
In order to develop
J2SE and these kinds of applications are preferred
trusted network in which there exists n number of
is also known as WAN. Using this network, we can
applications. A distributed application is one which runs on
In order to develop distributed applications

and trusted
inter
LAN. Using this
is one which
centralized
inter connected
multiple servers
we may use

History of java

History of JAVA:

JAVA is a distributed technology developed by James Gosling, Patric Naugton, etc., at Sun
Micro System has released lot of rules for JAVA and those rules are implemented by JavaSoft Inc,
USA (which is the software division of Sun Micro System) in the year 1990. The original name of JAVA
is OAK (which is a tree name). In the year 1995, OAK was revised and developed software called
JAVA (which is a coffee seed name).
JAVA released to the market in three categories J2SE (JAVA 2 Standard Edition), J2EE (JAVA 2
Enterprise Edition) and J2ME (JAVA 2 Micro/Mobile Edition).
i. J2SE is basically used for developing client side applications/programs.
ii. J2EE is used for developing server side applications/programs.
iii. J2ME is used for developing server side applications/programs.
If you exchange the data between client and server programs (J2SE and J2EE), by default JAVA is
having on internal support with a protocol called http. J2ME is used for developing mobile
applications and lower/system level applications. To develop J2ME applications we must use a
protocol called WAP (Wireless Applications Protocol).

Friday, October 28, 2016

C++(Absolute value)

Find the absolute value of a number entered by the user. 


int main()
{
      int a;
      cout<<"Enter any number:";
      cin>>a;
 
      if(a>0)
            cout<<"The absolute value of number is:"<<a;
      else
            cout<<"The absolute value of number is:"<<-(a);
 
      getch();
      return 0;

}

C++ basic program

Any integer is input by the user. Write a program to find out whether it is an odd number or even number. 

 int main()
{
      int a;
      cout<<"Enter any number : ";
      cin>>a;
 
      if(a%2==0)
            cout<<"The number is even";
      else
            cout<<"The number is odd";
      
      getch();
      return 0;

}

C++(Year,Months and Days)

Write a program which accepts days as integer and display total number of years, months and days in it.
for example :  If user input as 856 days the output should be 2 years 4 months 6 days.
 

#include<iostream.h>
#include<conio.h>
 
int main()
{
      int days,y,m,d;
      cout<<"Enter no. of days : ";
      cin>>days;
      y=days/365;
      days=days%365;
      m=days/30;
      d=days%30;
      cout<<"Years : "<<y<<"\nMonths : "<<m<<"\nDays : "<<d;
 
      getch();
      return 0;

}

C++(Display Next Character)

Write a program which accepts a character and display its next character. 
Sol:  #include<iostream.h>
#include<conio.h>
 
int main()
{
      char ch;
      cout<< "\nEnter any character : ";
      cin>>ch;
      ch++;
      cout<<"Next character is : "<<ch;
 
      getch();
      return 0;

}

C++(Display No. Of Notes)

Write a program which accepts amount as integer and display total number of Notes of Rs. 500, 100, 50, 20, 10, 5 and 1.
For example, when user enter a number, 575,
the results would be like this...
500: 1
100: 0
50: 1
20: 1
10: 0
5: 1
1: 0
 
Sol:
#include<iostream.h>
#include<conio.h>
 
int main()
{
      int amt,R500,R100,R50,R20,R10,R5,R1;
      cout<<"Enter amount : ";
      cin>>amt;
      R500=amt/500;
      amt=amt%500;
      R100=amt/100;
      amt=amt%100;
      R50=amt/50;
      amt=amt%50;
      R20=amt/20;
      amt=amt%20;
      R10=amt/10;
      amt=amt%10;
      R5=amt/5;
      amt=amt%5;
      R1=amt;
      cout<<"Rs.500 : "<<R500<<"\nRs.100 : "<<R100<<"\nRs. 50 : "<<R50<<
            "\nRs. 20 : "<<R20<<"\nRs. 10 : "<<R10<<"\nRs.  5 : "<<R5<<"\nRe.  1 : "<<R1;
 
      getch();
      return 0;

}

C++(Display Largest Number)


Write a program which input three numbers and display the largest number using ternary operator.

 #include <iostream.h>
#include <conio.h>
 
int main()
{
      int a,b,c,greatest;
      cout<<"Enter three numbers : ";
      cin>>a>>b>>c;
      greatest=(a>b&&a>c)?a:(b>c)?b : c;
      cout<<"Greatest number is "<<greatest;
 
      getch();
      return 0;
}

C++(Check Even or Odd)

10
-Write a program to check whether the given number is even or odd (using ? : ternary operator ) 

#include<iostream.h>
#include<conio.h>
 
int main()
{
      int a;
      cout<<"Enter the Number : ";
      cin>>a;
      (a%2==0)?cout<<"Number is even":cout<<"Number is odd";
 
      getch();
      return 0;
}

C++(check Positive or Negative)

9
-Write a program to check whether the given number is positive or negative  (using ? : ternary operator ) 

#include<iostream.h>
#include<conio.h>
 
int main()
{
      int a;
      cout<<"Enter any non-zero Number : ";
      cin>>a;
      (a>0)?cout<<"Number is positive":cout<<"Number is negative";
 
      getch();
      return 0;
}

C++(Calculate Area)

8
- Write a program to calculate area of circle. 

#include<iostream.h>
#include<conio.h>
int main()
{
      float r,area;
      cout<< "\nEnter radius of circle : ";
 
      cin>>r;
      area = 3.14*r*r;
 
      cout<<"Area of circle : "<<area;
 
      getch();
      return 0;
}

C++(Swap The Values)

7-
Write a program to swap the values of two variables. 

#include<iostream.h>
#include<conio.h>
 
int main()
{
      int a,b,temp;
      cout<<"\nEnter two numbers : ";
      cin>>a>>b;
      temp=a;
      a=b;
      b=temp;
      cout<<"\nAfter swapping numbers are : ";
      cout<<a<<" "<<b;
 
      getch();
      return 0;
}

C++(Display ASCII Value)

6 -
Write a program which accepts a character and display its ASCII value. 

#include<iostream.h>
#include<conio.h>
 
int main()
{
      char ch;
      cout<< "\nEnter any character : ";
      cin>>ch;
      cout<<"ASCII equivalent is : "<<(int)ch;
 
      getch();
      return 0;
}

C++(Simple Intrest)

5-
Write a program which accept principle, rate and time from user and print the simple interest. 

#include<iostream.h>
#include<conio.h>
 
int main()
{
      int p,r,t,i;
      cout<<"Enter Principle : ";
      cin>>p;
      cout<<"Enter Rate : ";
      cin>>r;
      cout<<"Enter Time : ";
      cin>>t;
      i=(p*r*t)/100;
      cout<<"Simple interest is : "<<i;
 
      getch();
      return 0;
}