VIDHYA BHAWAN POLYTECHNICCOLLEGE
SUMMER INTERNSHIP
Name : Niraj Sahu
Year : 3rd
Year
Branch : Information Technology
2.
BASIC CONCEPTS OFOOP’s
• Inheritance
One class can acquire the property of the parent
class.
• Abstraction
the process of hiding unnecessary details
and exposing only the essential
information to the user
3.
• Polymorphism
The abilityof object to take more than one form.
There are 2 types of Polymorphism
1. Compile time polymorphism
2. Run time polymorphism
4.
Basic program java
importjava.util.Scanner;
public class scanf
{
public static void main(String[] args)
{
int a;
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
System.out.print(a);
}
}
5.
Compile time polymorphism
(methodoverloading)
public class MathOperations {
// Method to add two numbers
public int add(int a, int b) {
return a + b;
}
// Method to add three numbers
public int add(int a, int b, int c) {
return a + b + c;
}
public static void main(String[] args) {
MathOperations math = new MathOperations();
System.out.println(math.add(5, 10)); // Calls the method with 2 parameters
System.out.println(math.add(1, 2, 3)); // Calls the method with 3 parameters
}
6.
Types of JavaApplications
Standalone applications : Type of software program that is
designed to run on a single computer or local machine of
the user, without the need for a server or internet
connection
Applet : a small program that is embedded in another
application or software platform to perform a specific
task.
Servlet : a Web or application server that provides server-
side processing such as e-commerce and database search.
7.
Variable
• Instance variable: a variable that is declared in a
class but outside of any method, constructor, or
block.
• Static variable : a variable that is shared
among all instances of a class, rather than
being specific to each instance.
• Local variable :a temporary variable that is
only available while a function or block of
statements is being executed.
8.
Instance Variable
public classtypesvar
{ static int a=20;
static int b; // static variable default value =0
boolean d; //defualt value = false
int c; //instance variable default value =0
typesvar(){
System.out.println(d);
System.out.println(c);
}
public static void main(String[] args)
{
typesvar t=new typesvar();
System.out.println(b);
System.out.println(t.c);
}
}
9.
Static Variable
public classtypesvar
{
static int a =20;
static int b; // static variable default value =0
boolean d; //defualt value = false
int c; //instance variable default value =0
public static void main(String[] args)
{
typesvar t=new typesvar();
System.out.println(b);
System.out.println(t.c);
}
}
10.
Local Variable
public classTest
{
Void print()
{
int x =10;
}
Public static void main(String []args)
{
int a = 5;
System.out.println(a);
System.out.println(x);
}
}
11.
ARRAY
• array itis used to store multiple number of
elements of single type
• the length of array is established at the time of
array creation
• after creation the length is fixed.
• the element of array can be accesses by index
vale
• it index begins from zero
12.
public class test{
publicstatic void main(String []args)
{
int a[] = new int[2];
a[0] = 25;
a[1] = 2;
System.out.println(a[1]);
String b[]= new String []{“hi”,”hello”,”bye”};
System.out.println(b[2]);
}
13.
Frame in java
Frame:
• Frame is a top-level window with a title and a border.
• The size of the frame includes any area designated for the
border
14.
import java.awt.*; publicclass frame
{
public static void main(String a[])
{
Button b = new Button();
Frame f= new Frame();
f.setTitle("Title");
f.setBackground(Color.blue);
f.setSize(30,10);
f.setLayout(new FlowLayout());
f.setVisible(true);
b.setSize(20,20);
f.add(b);
}
}