Posts

Showing posts from August, 2021

tuesday Thread revision

  package com.company ; class myThread extends Thread { int i = 0 ; public void run () { while ( i < 1000 ) { System . out . println ( "Hello i am inside run method in myThread class" ); i ++; } } public void meth () { while ( i < 1000 ) { System . out . println ( "Prantika bahut acchi hai!" ); i ++; } } } class hello implements Runnable { int a = 0 ; public void run () { while ( a < 1000 ) { System . out . println ( "I am implementing runnable interface" ); a ++; try { Thread . sleep ( 78888 ); } catch ( InterruptedException e ) { e . printStackTrace (); } } } } public class CWR_Tuesday { public static void main ( String [] args ) { myThread obj = new myThread (); hello obj1 = new hello (); Thread first = new Thread ( obj1 ); ...

class inside package and using vs Javac

Image
 

Monday Revision

  package com.company ; //import java.util.Scanner; interface one { public void sing (); private void hello (){ System . out . println ( "hello" ); } default void two (){ hello (); } } class four implements one { public void sing (){ System . out . println ( "Singing" ); }; } abstract class Shape { public void meth1 ( int a ){ System . out . println ( "Hello world " + a ); } public abstract void meth2 (); } class Rhombus extends Shape { @Override public void meth1 ( int a ){ System . out . println ( "Bye world!" ); } public void meth2 (){ System . out . println ( "Rohan Kumar" ); } public void meth3 (){ System . out . println ( "Helooooo jeeeeeeeeee" ); } } /* class Animal1{ public Animal1(){ System.out.println("I am a constructor of Base class"); } public Animal1(String s){ ...

Sunday revision java

  package com.company ; class employee10 { int salary ; public employee10 (){ System . out . println ( "I am default constructor" ); } public int employee10 ( int salary ){ this . salary = salary ; return salary ; } } class sunday { int a = 0 ; String s = "rohan" ; public int getA () { return a ; } public void setA ( int a ) { this . a = a ; } public String getS () { return s ; } public void setS ( String s ) { this . s = s ; } } class factorial { public static int meth ( int n ) { if ( n == 0 || n == 1 ) { return 1 ; } else { return n * meth ( n - 1 ); } } } public class CWR_SundayRevision { public static void main ( String [] args ) { char [] ch = { '=' , 'r' , '3' , '@' , 'E' , '+' }; // Sweeping an array char v ...

Android project1

Image
  <? xml version ="1.0" encoding ="utf-8" ?> <RelativeLayout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: tools ="http://schemas.android.com/tools" android :layout_width ="match_parent" android :layout_height ="match_parent" tools :context =".MainActivity" android :background ="#000000" > <ImageView android :id ="@+id/image" android :layout_width ="match_parent" android :layout_height ="400dp" android :src ="@drawable/project1" /> <TextView android :id ="@+id/t1" android :layout_width ="wrap_content" android :layout_height ="wrap_content" android :text ="Rohan singh" android :fontFamily ="cursive" android :textSize ="34sp" android :layout_marginLef...

Android Happy birthday card

  <? xml version ="1.0" encoding ="utf-8" ?> <RelativeLayout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: tools ="http://schemas.android.com/tools" android :layout_width ="match_parent" android :layout_height ="match_parent" tools :context =".MainActivity" android :background ="#b39ddb" > <ImageView android :id ="@+id/image" android :src ="@drawable/my_pic" android :layout_width ="200dp" android :layout_height ="160dp" android :paddingTop ="16dp" /> <TextView android :id ="@+id/name" android :layout_width ="wrap_content" android :layout_height ="wrap_content" android :text ="Rohan singh" android :textStyle ="bold" android :textColor ="@...

JAVA Advance 2 practice set

  package com.company ; import java.io.File ; import java.io.FileWriter ; import java.io.IOException ; import java.util.Scanner ; interface rohan { void meth1 (); } class dep { @SuppressWarnings ( "dont" ) @Deprecated public void greet (){ System . out . println ( "Halllllo" ); } } public class CWH_112_PracticeSet { // P 3 @SuppressWarnings ( "Dont show any warning" ) public static void main ( String [] args ) { // Problem 2 // dep obj = new dep(); // obj.greet(); // p 4 // Method 1 // rohan r= new rohan() { // @Override // public void meth1() {System.out.println("hello jee");}}; // r.meth1(); //// Method 2 // rohan r1= ()->{ // System.out.println("hello jee"); // }; //r.meth1(); // p 5 // Creating a file for ( int c = 2 ; c <= 9 ; c ++) { File f = new File ( ...

File handling

  package com.company ; import java.io.File ; import java.io.FileNotFoundException ; import java.io.FileWriter ; import java.io.IOException ; import java.util.Scanner ; public class CWH_111_FileHandling { public static void main ( String [] args ) { // Code to create a new file File obj = new File ( "MyFirstJavaFile.txt" ); try { obj . createNewFile (); } catch ( IOException e ) { System . out . println ( "Unable to create new file: " ); e . printStackTrace (); } // code to write to a file try { FileWriter fileWriter = new FileWriter ( "MyFirstJavaFile.txt" ); fileWriter . write ( "This is our first file from this java course \n ok now bye " ); fileWriter . close (); } catch ( IOException e ) { System . out . println ( "Unable to write" ); e . printStackTrace (); } // ...