class Employee
{
String companyName = "TutorialRide.com";
public Employee(int empId, String name)
{
System.out.println("Employee Id : "+empId+"\nEmployee Name : "+name);
}
public void EmpMethod()
{
System.out.println("Company Name : "+companyName);
}
public static void main(String args[])
{
Employee emp = new Employee(101,"ABC");
emp.EmpMethod();
}
}
class ClassName
{
datatype variablename ;
datatype methodname( parameter )
{
method – body
}
}
public class Employee
{
String Name;
int EmpId;
int age;
double salary;
void empDept()
{
}
void empProject()
{
}
}
class OuterClass
{
class NestedClass
{
}
}
class OuterDemo
{
private int id = 101;
private String name = "CareerRide Info";
private class InnerDemo
{
void method()
{
System.out.println ("Id : "+id+" Name : "+name);
}
}
public static void main(String args[])
{
OuterDemo outer=new OuterDemo();
OuterDemo.InnerDemo innner=outer.new InnerDemo();
innner.method();
}
}
class OuterDemo
{
private int a = 40;
private int b =50;
void display()
{
int c = 60;
class LocalDemo
{
void method()
{
System.out.println("a + b + c = "+(a+b+c));
}
}
LocalDemo l = new LocalDemo();
l.method();
}
public static void main(String args[])
{
OuterDemo obj=new OuterDemo();
obj.display();
}
}
abstract class Bike
{
abstract void speed();
}
public class AnonymousDemo
{
public static void main(String args[])
{
int s = 50;
Bike bike=new Bike()
{
void speed()
{
System.out.println ("Speed of Bike : "+s+" Km/h" );
}
};
bike.speed();
}
}