Skip to content
Snippets Groups Projects
Commit 04691469 authored by Rajesh  D's avatar Rajesh D :speech_balloon:
Browse files

intial commit

parents
Branches master
No related tags found
No related merge requests found
Showing with 230 additions and 0 deletions
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/bin/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>java_og</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1736488099004</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
eclipse.preferences.version=1
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=21
/**
*
*/
/**
*
*/
module java_og {
}
\ No newline at end of file
package package_1;
public class sclname {
public String scl_name="Model";
protected int scl_id=66;
}
package package_1;
class stu{
private String stu_name="Rajesh";
protected int age=21;
void disp() {
System.out.println(stu_name);
}
}
public class student {
public static void main (String[] args) {
stu obj=new stu();
// System.out.println(obj.stu_name); // it gives error bcz private variables only accessible within that class
obj.disp(); // but we can call it through function
}
}
package package_1;
public class teacher {
public static void main(String[] args) {
stu obj=new stu(); // This is from student class
obj.disp();
System.out.println(obj.age); // This is Protected accessible within package
}
}
package package_2;
abstract class Animal{
abstract void makeSound();
}
class Dog extends Animal{
void makeSound() {
System.out.println("Dog Barks...");
}
}
class Cat extends Animal {
void makeSound() {
System.out.println("Cat Barks..");
}
}
public class abstract_exe {
public static void main(String[] args) {
Dog obj=new Dog();
Cat obj1=new Cat();
obj.makeSound();
obj1.makeSound();
}
}
package package_2;
class Person{
public String name;
protected int age;
private String socialSecurityNumber;
String address;
Person(String name,int age,String socialSecurityNumber,String address){
this.name=name;
this.age=age;
this.socialSecurityNumber=socialSecurityNumber;
this.address=address;
}
void disp2() {
System.out.print(socialSecurityNumber);
}
}
class Employee extends Person{
Employee(String n,int a,String ssn,String add) {
super(n,a,ssn,add);
System.out.println("Hello Employees");
}
}
public class acess_modifier {
public static void main(String[] args) {
Employee obj=new Employee("Rajesh",21,"xyxx1","KKD");
System.out.print(obj.name+"-"+obj.age+"-"+obj.address+"-");
obj.disp2();
}
}
package package_2;
abstract class Vehicle{
abstract void drive(int a);
final void startEngine() {
System.out.println("Engine Strated");
}
static String getVehicleType(String fuel) {
if(fuel=="petrol") {
return "vehicle is motorcycle";
}
else {
return "Vehicle is Car";
}
}
}
class car extends Vehicle{
void drive(int a) {
System.out.println("car drives at--"+a+" k/h");
}
}
class motorcycle extends Vehicle{
void drive(int a) {
System.out.println("MotorCycle drives at--"+a+" k/h");
}
}
public class combined_exe {
public static void main(String[] args) {
car c1=new car();
c1.startEngine();
System.out.println(Vehicle.getVehicleType("petrol"));
c1.drive(65);
motorcycle m1=new motorcycle();
m1.startEngine();
System.out.println(Vehicle.getVehicleType("diesel"));
m1.drive(95);
}
}
package package_2;
import package_1.sclname; // From Other Package
public class school extends sclname {
public static void main(String[] args) {
sclname obj=new sclname();
System.out.println(obj.scl_name);
// System.out.println(obj.scl_id); // It gives Error bcz the key was Protected
school obj1=new school(); // so we have to extend that class and create object for this class and we can access that
System.out.println(obj1.scl_id);
}
}
package package_2;
class Counter{
static int count=0;
int instancenum=0;
Counter(){
count=count+1;
instancenum=instancenum+1;
}
void disp() {
System.out.println("Static-" + count);
System.out.println("Instance-"+instancenum);
}
}
public class static_ex {
public static void main(String[] args) {
Counter obj=new Counter();
obj.disp();
Counter obj1=new Counter();
obj1.disp();
Counter obj2=new Counter();
obj2.disp();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment