java programming

package com.ashish;

public class BextendsClassA extends ClassA {
String s =”Child claass instance Variable”;
public void m1() {
System.out.println(s);
System.out.println(this.s);
System.out.println(super.s);
System.out.println(this.s);
System.out.println(super.s);
}

public static void main(String[]args) {

BextendsClassA b =new BextendsClassA();
b.m1();

}
}

package com.ashish;

public class BooleanExample5 {

public static void main(String[] args) {

    int num=7;
    boolean flag=false;

      for(int i=2;i<num;i++)
      {
          if(num%i==0)
          {
              flag=true;
                      break;
          }
      }
    if(flag)
    {
        System.out.println("Not prime");
    }
    else
    {
        System.out.println("prime");
    }

}       

}

package com.ashish;

public class ClassA {
String s=”parent class instance variable”;
//inheritance – class A extends B
//super and this – to call the parent and child class instance variable respectively

}

package com.ashish;

public class ConsstructorOverride {

ConsstructorOverride(){
System.out.println("Constructor with no passing parameter");

}
ConsstructorOverride(int a, String Name){
    System.out.println("Two passing Parameters");
}
ConsstructorOverride(int a, String Name, long MobileNo, char b){
    System.out.println("Three Passing Parameters");
}

public static void Main(String[]args) {
    ConsstructorOverride co = new ConsstructorOverride();

    ConsstructorOverride cp = new ConsstructorOverride(10, "ashish" );
    ConsstructorOverride cv = new ConsstructorOverride(96, "ashish", 966506611, 'a');






}

}

package com.ashish;

public class Const {

    int id;
    String name;
    Student3(int id, String name){
    this.id;
    this.name;
    }

    void display(){System.out.println(id+" "+name);}

    public static void main(String args[]){
    Student3 s1=new Student3(502, ashish);
    System.out.println(s1.id + "is" + s1.name)
    Student3 s2=new Student3(503, harish);
    s1.display();
    s2.display();
    }
    }

}

package com.ashish;

public class Constructorcall {
double d;

Constructorcall(double d){
    this.d=d;

    System.out.println("double args constructor");

}

Constructorcall(int i){

    System.out.println("int args constructor");

}
Constructorcall(){
    this(10);
    System.out.println("0 argument Constructor");
}
public static void main(String[]args) {
    Constructorcall c = new Constructorcall(10.5);
    System.out.println(c.d);
    Constructorcall C = new Constructorcall(13.5);
    System.out.println(C.d);
Constructorcall c1 = new Constructorcall(10);
Constructorcall c2 =new Constructorcall();
    Constructorcall c3 = new Constructorcall();

}

}

//Output:
//0 argument Constructor
//int args constructor

package com.ashish;

public class ConstructorCalling {
ConstructorCalling(){

}

ConstructorCalling(int a){
this(10,”ashish”);
System.out.println(“int argument constructor”);

}
ConstructorCalling(int b,int c){

}
ConstructorCalling(int a,String s){

}
}

package com.ashish;

public class ConstructorDemo {
String Name;
int roll_no;
ConstructorDemo(String Name,int roll_no){
this.Name = Name;
this.roll_no=roll_no;
}

public static void main(String[]args) {
ConstructorDemo e1= new ConstructorDemo(“Ashish”,100);
System.out.println(e1.Name +”=” +e1.roll_no);
ConstructorDemo e2= new ConstructorDemo(“Shrikant”,101);
System.out.println(e2.Name +”=” +e2.roll_no);
ConstructorDemo e3= new ConstructorDemo(“Sachin”,102);
System.out.println(e3.Name +”=” +e3.roll_no);

}
}

package com.ashish;

public class ConstructorPractice {
String Name;
float Marks;

ConstructorPractice(String Name, float Marks){
this.Name=Name;
this.Marks=Marks;

}
public static void Main(String[]args) {
ConstructorPractice cp=new ConstructorPractice(“Krishna”, 98.56f);
System.out.println(cp.Name +”have” + cp.Marks);

}

}

package com.ashish;

public class ConstructorPro {
int a;
int b;
public void m1(int a,int b) {
this.a=a;
this.b=b;
}
public static void main(String[]args) {

ConstructorPro cp =new ConstructorPro();
cp.m1(10, 20);
System.out.println(cp.a+ ” and ” +cp.b);

ConstructorPro pro =new ConstructorPro();
pro.m1(15,30);
System.out.println(pro.a+” and “+pro.b);
}
}

package com.ashish;

public class ConstructorPro {
int a;
int b;
public void m1(int a,int b) {
this.a=a;
this.b=b;
}
public static void main(String[]args) {

ConstructorPro cp =new ConstructorPro();
cp.m1(10, 20);
System.out.println(cp.a+ ” and ” +cp.b);

ConstructorPro pro =new ConstructorPro();
pro.m1(15,30);
System.out.println(pro.a+” and “+pro.b);
}
}

package com.ashish;

public class Constructors {
char ch;
int c;

public static void main(String[]args) {
    Constructors co= new Constructors();
    co.ch='a'; co.c=10;
    System.out.println(co.ch + " = " + co.c);
    Constructors cb= new Constructors();
    cb.ch='d'; cb.c=20;
    System.out.println(cb.ch + " = " +cb.c);    
}

}

package com.ashish;

import java.util.Scanner;

public class ConvertFootMeter {
public static void main(String[] args) {
double Feet;
double Meter;

Scanner Sc=new Scanner(System.in);
System.out.print("Enter a Value of feet");

Feet = Sc.nextDouble();
Meter = Feet*0.305;
System.out.println(Feet + ” feet is “+ Meter + ” Meter”);
}
}

package com.ashish;

public class DashCam {

public static void main(String[]args) {

    int num =7;
    boolean flag = false;
    for(int i=2;i<num;i++) 
    {
            if(num%i==0)
        {
            flag = true;
            break;

        }

    }
    if(flag)
    {
        System.out.println("No Prime");

    }
    else
    {
        System.out.println("Prime");
    }
    }   

}

package com.ashish;

public class DefaultValues {

int a;
String s;
boolean b;
static byte w;






public static void main(String[] args) {
    int x=10;

    DefaultValues obj = new DefaultValues();
    System.out.println(x);
obj.a=100;  
System.out.println(obj.a);
System.out.print(obj.b);
System.out.println(obj.s);

System.out.println(w);

System.out.println();
}
}

package com.ashish;

public class Demo {
public static void Main(String[]args) {
byte a=1;
a=1;

short b = 3276;
int c = 5873;
long v = 6758987l;
System.out.println(v);
float d = 100.12f;
float f=111;
float g = 1.111111111111f;
System.out.println(d);
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(f);
System.out.println(g);

}
}

package com.ashish;

public class Enquiry {
Enquiry(){

}
Enquiry(String name,String Email,long MN,String branch){

}
Enquiry(String name,String Email,String branch){

}

Enquiry(String name, String branch){

}
Enquiry(String name){

}
}

package com.ashish;
import java.util.Scanner;

public class Hello {

public static void main(String[] args) {

int a =10;
int b = 20;
int sum=a+b;
System.out.println(a);  
System.out.println(b);
System.out.println(sum);

int j = a*10;

System.out.println(j);
float e = 15.26f;
byte g = -128;
System.out.println(g);
System.out.println(e);

int v= 20;
System.out.println(v);
System.out.println("v");    

byte s=111;
int d=113;

short x = 3276;
int h = 5873;
long f = 6758987l;
System.out.println(x);
float q = 100.12f;
float i=111;
float t = 1.111111111111f;
System.out.println(d);
System.out.println(f);
System.out.println(j);
double y = 1.356897545621551421;
System.out.println(y);
char a1= ‘q’;

System.out.println(a1);

char m = ‘$’;
System.out.println(m);
boolean I = false;
System.out.println(I);
String k = “äshish”;
System.out.println(k);

//System.out.println(k+” “+1);
//System.out.println(1+2);

//System.out.println(“ömkar”+”Shrikant”);

System.out.println(“ömkar”+”Shrikant”);

System.out.println(“Taking input from user”);
Scanner sc = new Scanner(System.in);
System.out.println(“Enter Number 1”);
int a11= sc.nextInt();
System.out.println(“Enter Number 2”);
int x1 = sc.nextInt();
int add = a11+x1;
System.out.println(“The Sum of these numbers is”);
System.out.println(add);

}

}

package com.ashish;
import java.util.Scanner;

public class Iff{
public static void main(String[]args)
{
Scanner s = new Scanner(System.in);
System.out.println(“Enter your age”);
int age = s.nextInt();

    if(age>18 && age<40)
    {
    System.out.println("you are eligible for govt job");}


    else {
        if (age>40 && age<60)
        System.out.print("you are not eligible for govt job");}
    else {
        if (age>60 && age<100)
        System.out.print("you are not eligible for govt job");
    }
    }

}




package com.ashish;
import java.util.Scanner;
public class IfUtil {

    public static void main(String[]args) {

        Scanner s = new Scanner(System.in);

        System.out.println("Enter your age");
        int age = s.nextInt();

        if(age>18 && age<90) {

            System.out.println("you can drive");
        }else {

            System.out.print("you cant drive");
        }
    }

}

package com.ashish;
import java.util.Scanner;

public class InputFromUser {
public static void Main(String[]args) {

Scanner SC = new Scanner (System.in);
System.out.println("Enter number 1");
int a = SC.nextInt();
SC.close();

System.out.println("Your name is " + a);

}
}

package com.ashish;

public class InstanceVary {
int a = 500;
int b = 600;
public void m2() {
System.out.println(a);
System.out.println(b);
}
public static void Main(String[]args) {
InstanceVary i= new InstanceVary();
i.m2();

}

}

package com.ashish;

public class InstanceVsStatic {

int a=12;
static int b=20;

public static void main(String[] args) {
InstanceVsStatic c =new InstanceVsStatic();
System.out.println(c.a);
System.out.println(c.b);
//change values of variables
c.a=999;
c.b=888;

System.out.println(c.a);
System.out.println(c.b);

InstanceVsStatic obj = new InstanceVsStatic();
System.out.println(obj.a);
System.out.println(b);

c.b=111;

InstanceVsStatic h=new InstanceVsStatic();
System.out.println(h.a);
System.out.println(h.b);

System.out.println(InstanceVsStatic.b);

}
}

package com.ashish;

import java.util.Scanner;

public class Jumbo {
public static void main(String[]args) {

System.out.println("Taking input from user");
Scanner sc = new Scanner(System.in);
System.out.println("Enter Number 1");
int a= sc.nextInt();
System.out.println("Enter Number 2");
int b = sc.nextInt();
int sum = a+b;
System.out.println("The Sum of these numbers is");
System.out.println(sum);
System.out.println();

System.out.println();

}
}

package com.ashish;

public class MethodCalling {
public void m1() {
m2();

    System.out.println("m1 method");



}
public void m2() {
    m3(10);

    System.out.println("m2 method");



}

public void m3(int a) {

System.out.println("m3 method");

}
public static void main(String[]args) {
    MethodCalling obj=new MethodCalling();

    obj.m1();
    obj.m2();

    StaticVary st=new StaticVary();
    st.m1();
    st.m2();
    StaticVary.m2();



}

}

package com.ashish;

public class PassingParameter {

public void m1(int a, char ch){

    System.out.println("m1 method");
    System.out.println(a);
    System.out.println(ch);

}
public static void m2(String str, double d) {
    System.out.println("m2 method");
    System.out.println(str);
    System.out.println(d);
}
public static void Main(String[]args) {
    PassingParameter ob=new PassingParameter();
    ob.m1(10,'a');
    m2("Ashish",15.22);







}

}

package com.ashish;
public class Percentage {
static int x=53;
static String s=”Maharashtra”;

public void m3() {
System.out.println(x);
System.out.println(s);
}
public static void Main(String[]args) {
Percentage p=new Percentage();
p.m3();
}
}

package com.ashish;

public class Practice16Aug {
static int x=53;
static String s=”Maharashtra”;

public void m3() {
System.out.println(x);
System.out.println(s);
}
public static void m1() {
int a =10;
System.out.println(a);

}

public static void Main(String[]args) {
Practice16Aug p=new Practice16Aug();
p.m3();
p.m1();
Practice16Aug.m1();

}
}

package com.ashish;

public class Practice1708 {
String x = “India”;
int a=300;

public void m1() {
    float g = 1.5f;
    System.out.println(x);
    System.out.println(a);

}
public static void m2() {

    Practice1708 q= new Practice1708();
    System.out.println(q.x);
    System.out.println(q.a);



}

public static void main(String[] args) {
Practice1708 p= new Practice1708();
p.m1();
p.m2();
m2();

}
}

package com.ashish;

public class Practice1908 {
static int a = 20;
int b = 30;
public void m1() {
System.out.println(a);
System.out.println(b);
}
public static void main(String[] args) {
Practice1908 p = new Practice1908();
System.out.println(Practice1908.a);
System.out.println(p.b) ;

     p.a=100;
     p.b=150;

     System.out.println(p.a);
     System.out.println(p.b);

     Practice1908 q =new Practice1908();
     System.out.println(a);
     System.out.println(q.b);


 }

}

package com.ashish;

public class Practice2108 {
public static void main (String[]args) {
char c = 112;
System.out.println(c);
char i = ch();
System.out.println(i);

}

public static char ch() {
char ch = ‘a’;
return ch;
}
}

package com.ashish;

public class Practice2208_1 {
int a = 23;
char c = ‘b’;
public void m1(int a, char b) {
System.out.println(a);
System.out.println(b);
System.out.println(this.a);
System.out.println(this.c);

}
public static void main(String[]args) {
Practice2208_1 obj= new Practice2208_1();
obj.m1(25,’e’);
byte y = obj.age();
System.out.println(y);

}
byte age() {
byte age = 18;
return age;
}
}

package com.ashish;

public class Practice2208 {
int a = 100;
int m1(int a) {
return this.a;
}
public static void main(String[]args) {
Practice2208 t= new Practice2208();
int x = t.m1(10);
System.out.println(x);

}

}

package com.ashish;
import java.util.Scanner;
public class Practice3108 {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println(“Enter employee ID”);
int eid =s.nextInt();
System.out.println(“enter employee name”);
String ename=s.next();
System.out.println(“enter employee salary”);
double salary=s.nextDouble();
if (salary>10000 && ename.startsWith(“o”))
{
System.out.println(“very good employee”);
}
else {
System.out.println(“good employee”);
}
}
}

package com.ashish;

public class PublicClass {

public void m3(int c,  float d) {

    System.out.println(c);
System.out.println(d);
}
public static void main(String[]args) {
PublicClass p=new PublicClass();
p.m3(10,1.66f);













}

}

package com.ashish;

public class Random {
int a=20;

        String s = "spring";
        public void m1() {
            System.out.println(a);
            System.out.println(s);

        }
        public static void Main(String[]string) {
            float g =1.5f;
            Random r =new Random();
            System.out.println(r.a);
            System.out.println(r.s);
            System.out.println(g);
            r.m1();

        }


        }

package com.ashish;

public class RecursiveConstructor {
int i;
RecursiveConstructor()
{this();

}
RecursiveConstructor(int i){
    this(10);



}
public static void main(String[]args) {
    RecursiveConstructor r =new RecursiveConstructor();
    System.out.println("hi");

}

}

package com.ashish;

public class ReturnStatement {
public static void main(String[]args) {
printAMessage();
int sum = add();
System.out.println(sum);
String sho =caps();
System.out.println(sho);
float f = tf();
System.out.println(f);
char g = ch(10);
System.out.println(g);
boolean j=bool();
System.out.println(j);

}

public static void printAMessage() {
System.out.println(“This is my first return type program”);
}
public static int add() {
int a = 10;
int b = 30;
return a*b;
}
public static String caps() {
String s=”Ashhsih”;
return s;

}
public static float tf() {
float f =15.22f;
return f;

}
public static char ch(int x) {
char ch=’A’;
return ch;

}
public static boolean bool() {
boolean b = false;
boolean a = true;
return b;

}
}

package com.ashish;

public class ReturnType {
float m1(int a) {
System.out.println(“pramod”);
System.out.println(a);
return 1.5f;
}
public static void main(String[]args) {
ReturnType o = new ReturnType();
o.m1(10);

}

}

package com.ashish;

public class StaticVary {
static String x =”India”;
static int a =300;

public void m1() {
float g =1.5f;
System.out.println(x);
System.out.println(a);

}
public static void m2() {
System.out.println(x);
System.out.println(a);

}
public static void main(String[]args) {
StaticVary s=new StaticVary();
s.m1();
m2();
}

}

package com.ashish;

public class StringConcatination {
public static void main(String[]args) {
int a=100;
int b=200;
double c=12.33;
double d=23.44;
String x = “Hello”;
String y =”world”;
System.out.println(x+y);
System.out.println(x+” “+y);
System.out.println(x+” “+y+” “+(a+b));
System.out.println(c+d);
System.out.println(a+b+x+y+c+d);
}
}

package com.ashish;

public class Students3 {

    int id;
    String name;
    Students3(String name, int id){
    this.id=id;
    this.name=name;
    }



    public static void main(String args[]){
    Students3 s1=new Students3("ashish", 502);
    System.out.println(s1.id + " is " + s1.name);
    Students3 s2=new Students3("harish",503);
    System.out.println(s2.id + "is" + s2.name);
    }
    }

package com.ashish;

public class ThisKeyword {//difference between X and x
int x = 190;//instance variable
int y = 200;//instance variable
static int z=300;

public void add(int x,int y) {
    System.out.println(x+y);
    System.out.println(this.x+this.y);//calling instance variables using this word

}
public void multiplication(int x,int y) {
    System.out.println(x*y);//why this happens
    System.out.println(this.x*this.y);

}
public void substraction(int X,int Y) {
    System.out.println(x-y);//if define x different than passing variable java executes instance variable
    System.out.println(X-Y);

}
public void test() {
    System.out.println(x+y);
    System.out.println(this.x+this.y);
}


static void division() {
int z =150;
System.out.println(z);
}

public static void main(String[]args) {
    ThisKeyword obj =new ThisKeyword();
    System.out.println(obj.x);
    System.out.println(obj.y);
    obj.add(20, 40);
    obj.division();
    ThisKeyword.division();
    obj.multiplication(15, 20);
    obj.substraction(60, 30);
    obj.test();


}

}

Published by naikashish22

I am seeking file of wonderful life

Leave a comment