0% found this document useful (0 votes)
3 views3 pages

Java Features and Programming Concepts

The document outlines the key features of Java, highlighting its simplicity, object-oriented nature, security, robustness, portability, and support for multithreading. It also discusses method overloading as a form of static polymorphism and provides a Java program example demonstrating this concept. Additionally, it introduces recursion, explaining its principles and providing a Java program for calculating the factorial of a number using recursive functions.

Uploaded by

naiduvamshidhar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Java Features and Programming Concepts

The document outlines the key features of Java, highlighting its simplicity, object-oriented nature, security, robustness, portability, and support for multithreading. It also discusses method overloading as a form of static polymorphism and provides a Java program example demonstrating this concept. Additionally, it introduces recursion, explaining its principles and providing a Java program for calculating the factorial of a number using recursive functions.

Uploaded by

naiduvamshidhar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

UNIT-1

*teatures of Java (Java Buzz words)


* Simple
* Object oriented
* Distributed
* Secure
* Robust
* porterpeded
* Multithreaded
* Architectural Neutral language
* High performance
* Dynamic
* Simple: -
Leaming and practicing java is Easy because of resemblance With
C and C++.
* Object oriented.
Java is an Object Oriented language because it Supposts classes, Objects, data
abstraction, data EnCapsulation, polymorphism, Inheatance, dynamic binding and
message passing.
* Distributed -
Java
is designed for use on netwölk. It has an Extensive
library which Walks in agrement with Tcp/ Ip.
* Secure:
Java is designed for use on Internet. It enables Construction of Virus - free and
tamper free Syslem.
* Rebust:
Java programs Cannot Crash because of its Exception handling features.
* Interpreted:
Java programs are Converted into bytecode after Compilation and then the byte Code
is interpreted by the interpreter, which is a past Of JVM.
* Portable:-
As java does not have machine dependent implementation features, it can wun on any
machine and yield the Same result.
* Multithreaded: -
Executing different pasts of a program Simultaneously is Knocon as Multithreading.
This feature Enables the development of server Side programs.
* Architectural neutel languager-
As java programs are Converted into byte Code, they Can run on any machine with any
process? and any operating system.
* High per famances-
Along With Interpreter, java Contains JIT (Just -IN- Time. Compiler which enhances
the speed of Execution.
* Dynamic: -
We Can develop java programs which change dynamically applets).

2Nd Question;
* Method overloading:-
Method overloading refers to the implementation of a method with different number
of parameters, different type of parameters, different return types and different
functionalities.
Method overloading is an example of static polymorphism.
// Java
program to implement Method overloading.
import [Link].*;
class Methodoverload 1•
{
public static void main (string args CI) throws Exception
{
int s,x, ch;
float 1, b, y : double arb, c,3;
Scanner sc=new Scanner (System in);
do
System. out printin C"mintt !
System. out. printin C"Ininits.. system. out. printin ("InIntt 3-
AREA OF SQUARE");
AREA
OF RECANGLE");
AREA OF TRIANGLE");
System. out. printin ("Ininlt 4...
System. out. printin ("IMInIt ENTER YOUR CHOICE...
"›;
ch= sc. next Int);
switch (ch)
~
case
System. out. printin("Ininit ENTER THE SIDE OF SQUARE..."*; s= sc• next Int ( );
x= arca (s);
System • out. printin ("IntnIt AREA OF SQUARE IS ...
" +x);
break;
CaSE 2:
System. out, printin("IntnItENTER THE LENGTH OF THE RECTANGLE....;
1= sonextFloat ();
System• out. printin ("IntnIt ENTER THE BREADTH OF THE RECTANGLE..-"); b= sc. next
Float);
y= area (1,b);
Syctem. out•printin("InInit AREA OF RECTANGLE 15 _ ...
"+y);
break;
Case 3:
System out-printin (IminIt ENTER THE LENGTH OF SIDE-I OF TRIANGLE...."); a= sc-
nextDoubled);
[Link]. print/n C"InInIt ENTER THE LENGTH OF SIDE-2 OF TRIANGLE_..."); b= sc•
nextouble ();
System. out printin ("InIn It ENTER THE LENGTH OF SIDE-3 OF TRIANGLE..."); c=sc-
nextDouble e );
3= area ca.b, c);
System. out-printin ("InInItTHE AREA OF TRIANGLE 1S..._"+3); break;
case 4:
System. exit (0);
default:
System• out printin("ninIt INVALID CHOICE.....");
break;
4 While (ch›=1 && Ch<= 3);
public
static int area (int s)
int P;
p = s*S;
retum (p);
public static float area (Hoat e, float b)
float p;
p= 1* b; return (p) ;
public static double arca (double a, double b, double c) double P,S;
S= (a+b+ 0/2 ;
P= Math. sqrt (s* (S-a)* (S-b)* (s-c)); retum (p);
4

* 3rdQuestion RECURSION:-
20
Recursion is the process of calling a function by itself.
Recursive function:-
A function which calls itself is called a Recursive function Recursion uses a data
structure known as stack.
A stack is a data structure which follows the principle of last - In - First-out
(LIFO)
Eg:- 1• Factorial of a number
2. 6co of two numbers
3. ToNers of Hanoi
4. Quick sort•
Factoria et a number:-
IlJava program to find the factorial of given number using recursion import
[Link].*;
class FactRec
public static void main (String args( ]) throws Exception int n, v;
Scanner sc=new Scanner ([Link]);
System-out. printin C"InInIt ENTER A NUMBER.
");
ทะ sc-nextInt();
v = fact (n);
Syctem. out. printin C'InInItTHE FACTORIAL VALUE 1S....
"+V) ;
public static int fact (int t)
if (t== 0)
retum (r) ;
eise
{
retur (t* fact (t-r));
4

You might also like