Posts

Showing posts from February, 2021

83.RandomAccessfile in java

 //randomaccessfile import java.io.*; import java.util.*; class randomaccessfile { public static void main(String[] args) { try { Scanner obj = new Scanner(System.in); int n, ch; long len; RandomAccessFile raf = new RandomAccessFile("File.txt","r"); len = raf.length(); System.out.print("Enter last character to Display : "); n = obj.nextInt(); if (n > len) { raf.seek(0); } else { raf.seek(len - 0); } raf.close(); } catch(Exception e) { System.out.println(e); } } } OUTPUT:

82.File Information in JAVA

 //fileinfo import java.io.*; class fileinfo { public static void main(String[] args) { try { File file = new File("C:\\Users\\Divyesh\\Desktop\\java\\File.txt"); System.out.println("getName() = " + file.getName()); System.out.println("getParent() = " + file.getParent()); System.out.println("getPath() = " + file.getPath()); System.out.println("isFile() = " + file.isFile()); System.out.println("isDirectory() = " + file.isDirectory()); System.out.println("canRead() = " + file.canRead()); System.out.println("canWrite() = " + file.canWrite()); System.out.println("exists() = " + file.exists()); System.out.println("isHidden() = " + file.isHidden()); System.out.println("length() = " + file.length()); } catch(Exception e) { System.out.println(e); } } } OUTPUT: getName() = File.txt getParent() = C:\Users\Divy

81.System.Out.Println() in java

//System.Out.Println() /* System is class java.lang.System printStream is Class java.io.printStream println is method of printStream class */ class sys { static pristr out = new pristr(); } class pristr { void println(String str) { System.out.println(str); } } class SystemOut { public static void main(String[] args) { sys.out.println("Welcome"); } }  OUTPUT: Welcome

80.FileinputeStream i n JAVA

 //FileinputeStream import java.io.*; class FileInputeStream1 { public static void main(String[] args) { try { FileInputStream fis = new FileInputStream("bytes.txt"); int ch; while((ch = fis.read()) != -1) { System.out.print( ch + "\t" ); } fis.close(); } catch(Exception e) { System.out.println(e); } } } OUTPUT: 1       2       3       4       5       6       7       8       9       10

79.FileOutputStream in JAVA

 //Byte Stream //FileOutputStream import java.io.*; class FileOutputStream1 { public static void main(String[] args) { try{ FileOutputStream fos = new FileOutputStream("bytes.txt"); for (int i = 1; i <= 10; i++) { fos.write(i); //String str = "Line : " + i; //byte arr[]  = str.getBytes(); //.write(arr); } fos.close(); } catch(Exception e) { System.out.println(e); } } } OUTPUT: text file : bytes.txt 1     2     3     4     5     6     7     8     9     10

78.BufferReader In JAVA

 //Buffereader import java.io.*; class Buffereader { public static void main(String[] args) { try { FileReader fr = new FileReader("buffer.txt"); BufferedReader br = new BufferedReader(fr); int ch; while((ch = br.read()) != -1) { System.out.print((char) ch ); } br.close(); fr.close(); } catch(Exception e) { System.out.println(e); } } } OUTPUT: ☺☻♥♦♣

77.BufferWriter in JAVA

 //Bufferwriter import java.io.*; class Bufferwriter { public static void main(String[] args) { try{ FileWriter fw = new FileWriter("buffer.txt"); BufferedWriter bw = new BufferedWriter(fw); for (int i = 1; i <= 10; i++) { bw.write(i); } bw.close(); fw.close(); } catch(Exception e) { System.out.println(e); } } } OUTPUT: Test file : buffer.txt  

76.FileReader IN JAVA

 //filereader import java.io.*; class filereader { public static void main(String[] args) { try { FileReader fr = new FileReader("my.txt"); int ch; while((ch = fr.read()) != -1) { System.out.print((char) ch ); } fr.close(); } catch(Exception e) { System.out.println(e); } } } OUTPUT: Milan Bakotra

75.FileWriter in JAVA

 //filewriter import java.io.*; class filewriter { public static void main(String[] args) { try{ FileWriter fw = new FileWriter("BCA"); for (int i = 1; i <= 10; i++) { fw.write("Line : " + i); fw.write("\n"); } fw.close(); } catch(Exception e) { System.out.println(e); } } } OUTPUT: NOTEPAD FILE "BCA.TXT" Line : 1 Line : 2 Line : 3 Line : 4 Line : 5 Line : 6 Line : 7 Line : 8 Line : 9 Line : 10

74.sychronization in java

 //sychronization class  Account { static int bal; Account() { bal = 0; } synchronized void deposit(int amt) { bal = bal + amt; } } OUTPUT: Balance : 1000000 class customer extends Thread { Account act; customer (Account ac) { act = ac; } public void run() { for (int i = 1; i <= 10000; i++) { act.deposit(10); } } } class sychronization { public static void main(String[] args) { Account acc = new Account(); customer cust[] = new customer[10]; int a; for (a = 0; a < 10; a++) { cust[a] = new customer(acc); cust[a].start(); } for (a = 0; a < 10; a++) { try{ cust[a].join(); } catch(Exception e) { System.out.println("Exception : " + e); } } System.out.println("Balance : " + acc.bal); } }

73.multi_threading in java

 //multi_threading class threaA extends Thread { public void run() { try { for (int i = 1; i <= 10; i++ ) { System.out.println("\t" + i); Thread.sleep(100); } } catch(Exception e) { System.out.println(e); } } } class threaB extends Thread { public void run() { try { for (int i = 10; i >= 1; i-- ) { System.out.println("\t" + i); Thread.sleep(100); } } catch(Exception e) { System.out.println(e); } } } class multi_threading { public static void main(String[] args) { threaA objA = new threaA(); threaB objB = new threaB(); objA.start(); objB.start(); try { objA.join(); objB.join(); } catch(Exception e) { System.out.println("Main : " + e); } System.out.println("End of main() Program"); } } OUTPUT:   1         10         9         2         3         8         4         7         5         6         5        

72.multi - threading by implementing runable interfce in java

 //multi - threading by implementing runable interfce  class MyThread2 implements Runnable { public void run() { try { for (int i = 10; i >= 1; i-- ) { System.out.println("\t" + i); Thread.sleep(100); } } catch(Exception e) { System.out.println(e); } } } class threading2 { public static void main(String[] args) { MyThread2 obj = new MyThread2(); Thread t = new Thread(obj); t.start(); System.out.println("End..."); } } OUTPUT: End...         10         9         8         7         6         5         4         3         2         1

71. multi - threading in java

 //multi - threading by extending Thread class  class MyThread extends Thread { public void run() { try { for (int i = 1; i <= 10; i++ ) { System.out.println("\t" + i); Thread.sleep(100); } } catch(InterruptedException e) { System.out.println(e); } } } class threading1 { public static void main(String[] args) { MyThread obj = new MyThread(); obj.start(); System.out.println("End of Program"); } } OUTPUT: End of Program         1         2         3         4         5         6         7         8         9         10

70.division using throws keyword

 //Division.java file //Throws keyword public class division { public void divide(int a, int b) throws ArithmeticException { int c = a / b; System.out.println("Division : " + c); } } ================================================================ //calculate2.java //throws keyword import java.util.*; class calculate2 { public static void main(String[] args) { Scanner obj = new Scanner(System.in); int x, y; System.out.print("Enter Value X : "); x = obj.nextInt(); System.out.print("Enter Value Y : "); y = obj.nextInt(); try { division div = new division(); div.divide(x, y); } catch(ArithmeticException ae) { System.out.println("Second Argument must be Non-Zero"); } } } OUTPUT: Enter Value X : 12 Enter Value Y : 3 Division : 4 ------------------------------------------------------------------------------------------ Enter Value X : 12 Enter Value Y : 0 Second Argument must be Non-Zero

69.throw keyword in java

 //throw keyword class throw1 { public static void main(String[] args) { try { //ArithmeticException obj = new ArithmeticException(); //throw obj; throw new ArithmeticException(); } catch(ArithmeticException ae) { System.out.println("Exception Caught"); } catch(Exception e) { System.out.println("Exception : " + e); } } } OUTPUT: Exception Caught

68. User Define Exception or Custom Exception in JAVA

 //User Define Exception or Custom Exception class ExceptionA extends Exception { ExceptionA(String msg) { super(msg); System.out.println(msg); } } class ExceptionB extends Exception { ExceptionB(String msg) { super(msg); System.out.println(msg); } } class user_define_exc { public static void main(String[] args) throws ExceptionA, ExceptionB { int n = Integer.parseInt(args[0]); if (n % 2 == 1) { throw new ExceptionA("Problem"); } else { throw new ExceptionB("Big Problem"); } } } OUTPUT: -------------------------------------------------------------------- java user_define_exc 5 Problem Exception in thread "main" ExceptionA: Problem         at user_define_exc.main(user_define_exc.java:25) --------------------------------------------------------------------- java user_define_exc 2 Big Problem Exception in thread "main" ExceptionB: Big Problem         at user_define_exc.main(user_define_exc

67.Exeption Handling in java

Image
 class Exeption_handling { public static void main(String[] args) { try { int a = Integer.parseInt(args[0]); int b = Integer.parseInt(args[1]); int c = a / b; System.out.println("Division : " + c); } catch(ArrayIndexOutOfBoundsException e) { System.out.println("Enter Two Argument"); } catch(NumberFormatException ne) { System.out.println("Enter Two Numaric Argument"); } catch(ArithmeticException ae) { System.out.println("Second Argument must be Non-Zero"); } catch(Exception e) { System.out.println("Exception : " + e); } finally { System.out.println("Finally block Execute"); } } } OUTPUT: =================================== java Exeption_handling 4 2 Division : 2 Finally block Execute ---------------------------------------------------------- java Exeption_handling Enter Two Argument Finally block Execute ----------------------------

66.Vector in JAVA

// Vector  is like the dynamic array which can grow or shrink its size. Unlike array, we can store n-number of elements in it as there is no size limit.  import java.util.*; class vector_class { public static void main(String[] args) { Vector v = new Vector(); System.out.println("Vector = " + v); System.out.println("Vector Capacity = " + v.capacity()); System.out.println("Vector Size = " + v.size()); v.add("one"); v.add("two"); v.add("three"); System.out.println("\nVector = " + v); System.out.println("Vector Capacity = " + v.capacity()); System.out.println("Vector Size = " + v.size()); for (int i = 1; i <= 10 ; i++ ) { v.add(i); } System.out.println("\nVector = " + v); System.out.println("Vector Capacity = " + v.capacity()); System.out.println("Vector Size = " + v.size()); for (int i = 11; i <= 20 ; i++ ) {

59.SortedList in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace sortedlist {     class Program     {         static void Main(string[] args)         {             SortedList s1 = new SortedList();             s1.Add("key1", 50);             s1.Add("key2", 60);             s1.Add("key3", 70);             s1.Add("key4", 80);             s1.Add("key5", 90);             foreach (DictionaryEntry sname in s1)             {                 Console.WriteLine("Key : " + sname.Key + "  And  Values : " + sname.Value);             }             Console.WriteLine("Size of Sorted List is :" + s1.Capacity);             s1.Capacity = 200;             Console.WriteLine("After Set Size of Sorted List is :" + s1.Capacity);             s1.TrimToSize();             Console.WriteLine("After Triming the Size of Sorted List is :

58. HashTable In C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace HashTable {     class Program     {         static void Main(string[] args)         {             Hashtable h1 = new Hashtable();             h1.Add("s1", "Milan");             h1.Add("s2", "Bakotra");             h1.Add("s3", "Divi");             h1.Add("s4", "Divu");             h1.Add("s5", "Vidhi");             foreach (DictionaryEntry sname in h1)             {                 Console.WriteLine("Key : " + sname.Key + "  And Value : " + sname.Value);             }             Console.WriteLine("ContainsKey() : " + h1.ContainsKey("s3"));             Console.WriteLine("Contains() : " + h1.Contains("s6"));             Console.WriteLine("ContainsValue() : " + h1.Contai

57.ArrayList in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace arraylist {     class Program     {         static void Main(string[] args)         {             ArrayList arr1 = new ArrayList();             arr1.Add("Milan");             arr1.Add("Krunal");             arr1.Add("Divya");             arr1.Add("Riya");             arr1.Add("Divi");             foreach (String val in arr1)             {                 Console.WriteLine(val);             }             Stack s1 = new Stack();             s1.Push(5);             s1.Push(15);             s1.Push(25);             s1.Push(35);             s1.Push(45);             Console.WriteLine("====  After Add StackObject into arraylist ====");             arr1.AddRange(s1);             foreach(object val in arr1)             {                 Console.WriteLine(val);             }            

65. Stack class in java

 //stack_class import java.util.*; class stack_class { public static void main(String[] args) { Stack obj = new Stack(); obj.push(5); obj.push(15); obj.push(25); obj.push(35); obj.push(45); System.out.println("Stack : " + obj); System.out.println("pop(Delete) : " + obj.pop());      } } OUTPUT: Stack : [5, 15, 25, 35, 45] pop(Delete) : 45

64. Hashtable class in JAVA

 //Hashtable class  import java.util.*; class HashtableDemo { public static void main(String[] args) { Hashtable obj = new Hashtable(); obj.put("Apple", "Red"); obj.put("Banana", "Yellow"); System.out.println("The color of Apple is : " + obj.get("Apple")); Enumeration e = obj.keys(); while(e.hasMoreElements()) { String k = e.nextElement().toString(); String v = obj.get(k).toString(); System.out.println("\tkey : " + k + "\tValue : " + v); } } } OUTPUT: The color of Apple is : Red         key : Apple     Value : Red         key : Banana    Value : Yellow

63. StringTokenizer_class in JAVA

 //StringTokenizer_class import java.util.*; class StringTokenizer_class { public static void main(String[] args) { Scanner obj = new Scanner(System.in); String str; System.out.println("Enter Any String : "); str = obj.nextLine(); StringTokenizer tokens = new StringTokenizer(str , " "); while(tokens.hasMoreTokens()) { System.out.println(tokens.nextToken()); } } } OUTPUT: welcome to java programming welcome to java programming

62. simple_time_zone_class in JAVA

 //simple_time_zone_class import java.util.*; class simple_time_zone_class { public static void main(String[] args) { SimpleTimeZone obj = new SimpleTimeZone(730,"Australia"); System.out.println("Time Zone : " + obj); System.out.println("Object Clone : " + obj.clone()); } } OUTPUT: Time Zone : java.util.SimpleTimeZone[id=Australia,offset=730,dstSavings=3600000,useDaylight=false,startYear=0,startMode=0,startMonth=0,startDay=0,startDayOfWeek=0,startTime=0,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0] Object Clone : java.util.SimpleTimeZone[id=Australia,offset=730,dstSavings=3600000,useDaylight=false,startYear=0,startMode=0,startMonth=0,startDay=0,startDayOfWeek=0,startTime=0,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0]

61.GregorianCalendar class in JAVA

 //GregorianCalendar class import java.util.*; class gregoriancalendar { public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(); //System.out.println(cal); System.out.println("Year : " + cal.get(Calendar.YEAR)); System.out.println("Month : " + cal.get(Calendar.MONTH)); System.out.println("Date : " + cal.get(Calendar.DATE)); System.out.println("\nHour : " + cal.get(Calendar.HOUR)); System.out.println("Minute : " + cal.get(Calendar.MINUTE)); System.out.println("Second : " + cal.get(Calendar.SECOND)); System.out.println("\nDay of Week : " + cal.get(Calendar.DAY_OF_WEEK)); System.out.println("Day of Month : " + cal.get(Calendar.DAY_OF_MONTH)); System.out.println("Day of Year : " + cal.get(Calendar.DAY_OF_YEAR)); } } OUTPUT: Year : 2021 Month : 1 Date : 17 Hour : 9 Minute : 47 Second : 33 Day of Week : 4 Day of Month : 17 Day of

56.Queue Class Example in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace queue {     class Program     {         static void Main(string[] args)         {             Queue q1 = new Queue();             q1.Enqueue(5);             q1.Enqueue(15);             q1.Enqueue(25);             q1.Enqueue(35);             q1.Enqueue(45);             foreach (int var in q1)             {                 Console.WriteLine(var);             }             Console.WriteLine("==== After Dequeue ====");             q1.Dequeue();             q1.Dequeue();             foreach (int var in q1)             {                 Console.WriteLine(var);             }             Console.WriteLine("Peek() Result is:" + q1.Peek().ToString());             Console.WriteLine("Total Element in Queue is :" + q1.Count);             Console.WriteLine("Contains () Result is :" + q1.Contains(3));          

55. Stack class in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace stack_class {     class Program     {         static void Main(string[] args)         {             Stack s1 = new Stack();             s1.Push(5);             s1.Push(15);             s1.Push(25);             s1.Push(35);             s1.Push(45);             foreach (int val in s1)             {                 Console.WriteLine(val);             }                          s1.Pop();             s1.Pop();             Console.WriteLine("==== After POP operation ====");             foreach (int val in s1)             {                 Console.WriteLine(val);             }             Console.WriteLine("Peek Operation : " + s1.Peek());             Console.WriteLine("Contains Operation : " + s1.Contains(25));             Console.WriteLine("Total Element : " + s1.Count);             Console.WriteLine(

54.multicasting delegate in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace multicasting_delegate {     public delegate void Delegate_op(double a, double b);     class Program     {         static void mul(double x, double y)         {             Console.WriteLine("Multiplication : " + x * y);         }         static void add(double x, double y)         {             Console.WriteLine("Addition : " + (x + y));         }         static void div(double x, double y)         {             Console.WriteLine("Division : " + x / y);         }         static void sub(double x, double y)         {             Console.WriteLine("Substraction  : " + (x - y));         }         static void Main(string[] args)         {             Delegate_op obj = new Delegate_op(mul);             obj += new Delegate_op(add);             obj += new Delegate_op(sub);             obj += new Delegate_op(div);               

53.Delegate as class data member

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace delegate_as_class_data_member {     public delegate void Delgate_op(string msg);     class delegate_class     {         public static void wlc(string msg)         {             Console.WriteLine("Welcome " + msg);         }         public static void Bye(string msg)         {             Console.WriteLine("Bye " + msg);         }     }     class Program     {         static void Main(string[] args)         {             Delgate_op obj = new Delgate_op(delegate_class.wlc);             obj("Milan");             obj = delegate_class.Bye;             obj("Milan");             Console.Read();         }     } } OUTPUT: Welcome Milan Bye Milan

52.Delegate without argument without return value in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace delegate2 {     public delegate void Delegate();     class Program     {         static void hi()         { Console.WriteLine("HI... "); }         static void welcome()         { Console.WriteLine("Welcome to The C# Programming"); }         static void Main(string[] args)         {             Delegate obj_del = new Delegate(hi);             obj_del();             obj_del = welcome;             obj_del();             Console.Read();         }     } } OUTPUT: HI... Welcome to The C# Programming

51.Delegate with argument with return value in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace simple_delegate {     public delegate double Demo(double a, double b);      class Program     {         static double mul(double x, double y)         { return x * y;  }         static double add(double x, double y)         { return x + y; }         static void Main(string[] args)         {             Demo obj_del1 = new Demo(mul);             Demo obj_del2 = new Demo(add);             Console.Write("Enter First Value : ");             double d1 = Convert.ToDouble(Console.ReadLine());             Console.Write("Enter Second Value : ");             double d2 = Convert.ToDouble(Console.ReadLine());             double ans1 = obj_del1(d1, d2);             Console.WriteLine("Multiplication : " + ans1);             double ans2 = obj_del2(d1, d2);             Console.WriteLine("Addition : " + ans2);             Console.Read();  

60. Random class In java

 //Random class import java.util.*; class random_class { public static void main(String[] args) { Random obj = new Random(); System.out.println(obj.nextInt()); System.out.println(obj.nextInt(1000)); for (int i = 0; i < 10 ; i++ ) { System.out.println(obj.nextInt()); } } } OUTPUT: -328552001 116 -2009740136 -1779883719 -188711011 1673762916 -243162010 46344096 -1823513727 -1413869968 249453090 1171725984

59. wrapped_class2

//wrapper classes class wrapped_class2 { public static void main(String[] args) { int a = Integer.parseInt(args[0]); int b = Integer.valueOf(args[1]).intValue(); int mul = a * b; System.out.println("Multiplication  : " + mul); } } OUTPUT: java wrapped_class2 10 20 Multiplication  : 200

58. Date class in java

 //java.util.Date class import java.util.*; class java_Date_class { public static void main(String[] args) { Date d = new Date(); System.out.println(d); System.out.println("Year : " + (d.getYear() + 1900)); System.out.println("Month : " + d.getMonth()); System.out.println("Date : " + d.getDate()); Date birthdate = new Date(121, 02, 15); System.out.println("d.after(birthdate) : " + d.after(birthdate)); System.out.println("d.before(birthdate) : " + d.before(birthdate)); System.out.println("d.equals(birthdate) : " + d.equals(birthdate)); } }  OUTPUT: Mon Feb 15 21:56:57 IST 2021 Year : 2021 Month : 1 Date : 15 d.after(birthdate) : false d.before(birthdate) : true d.equals(birthdate) : false

57.Wrapped Class in JAVA

 //wrapped class class wrapped_class { public static void main(String[] args) { Integer obj = new Integer(25); String str = obj.toString(); System.out.println("String = " + str); int no = 22; Integer obj2 = new Integer(no); String str2 = obj2.toString(); System.out.println("String2 : " + str2); } }  OUTPUT: String = 25 String2 : 22

50. Pointer to Array in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace poiter_to_arrray_fixed {     class Program     {         public static unsafe void printall(int* ptr)         {             for (int i = 0; i < 10; i++)             {                 Console.WriteLine(*(ptr + i));             }         }         static unsafe void Main(string[] args)         {             int[] arr = new int[10];             for (int count = 0; count < 10; count++)             {                 arr[count] = count * count;             }             fixed (int* ptr = arr)                 printall(ptr);             Console.Read();         }     } } OUTPUT: 0 1 4 9 16 25 36 49 64 81

49.swap_value_uisng_pointer

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace swap_value_uisng_pointer {     class Program     {         unsafe public static void swap(int* x, int* y)         {             int temp;             temp = *x;             *x = *y;             *y = temp;         }         static unsafe void Main(string[] args)         {             int a = 33;             int b = 22;             Console.WriteLine("Before Swamp() : a={0}, b={1}", a, b);             swap(&a, &b);             Console.WriteLine("After Swap() : a={0}, b={1}", a, b);             Console.Read();         }     } } OUTPUT: Before Swamp() : a=33, b=22 After Swap() : a=22, b=33

48.pointer in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace pointer {     class Program     {         unsafe static void Main(string[] args)         {             int a = 10;             int b = 30;             int* ptr = &a;             int* ptr1 = &b;             Console.WriteLine("A = {0}  *ptr = {1}  (int)ptr = {2}",x, *ptr, (int)ptr);             Console.WriteLine("A = {0}  *ptr1 = {1}  (int)ptr1 = {2}", x, *ptr1, (int)ptr1);                Console.Read();         }     } } OUTPUT: A = 10  *ptr = 10  (int)ptr = 111209320 A = 30  *ptr1 = 30  (int)ptr1 = 111209316

47.Indexer in C#

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace indexerexample {     class clsindexer     {         private string[] range = new string[10];         public string this[int indexrange]         {             get { return range[indexrange]; }             set { range[indexrange] = value; }         }     }     class Program     {         static void Main(string[] args)         {             clsindexer obj = new clsindexer();             obj[0] = "Raj";             obj[1] = "Rahul";             obj[2] = "Deep";             obj[3] = "Faizan";             obj[4] = "Rutvik";             obj[5] = "Jaydeep";             Console.WriteLine("Obj[0]=" + obj[0]);             Console.WriteLine("obj[1]=" + obj[1]);             Console.WriteLine("obj[2]=" + obj[2]);             Console.WriteLine("obj[3]=" + obj[3]);            

56. java.lang.String class

Image
 

46.Nasted Namespace

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace nestednamepsaceexample {     namespace FYBCA     {         namespace SYBCA         {             class SYBCA_Class             {                 public static void hello()                 {                     Console.WriteLine("Hello");                     Console.Read();                 }             }         }     }     class Program     {         static void Main(string[] args)         {             FYBCA.SYBCA.SYBCA_Class obj = new FYBCA.SYBCA.SYBCA_Class();             FYBCA.SYBCA.SYBCA_Class.hello();         }     } } OUTPUT: Hello

45. multiple_namespace

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace multiple_namespace {     namespace namespace1     {         class A         {             public void print()             {                 Console.WriteLine("This is First Namespace");             }         }     }     namespace namespace2     {         class A         {             public void print2()             {                 Console.WriteLine("This is second Namespace");             }         }     }     class Program     {         static void Main(string[] args)         {             namespace1.A obj = new namespace1.A();             namespace2.A obj2 = new namespace2.A();             obj.print();             obj2.print2();             Console.Read();         }     } } OUTPUT: This is First Namespace This is second Namespace

44.Simple Namespace

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace simple_namespace {     namespace first_namespace     {         class demo         {             public void print()             {                 Console.WriteLine("This is first simple namespace");             }         }     }     class Program     {         static void Main(string[] args)         {             first_namespace.demo obj = new first_namespace.demo();             obj.print();             Console.Read();         }     } } OUTPUT: This is first simple namespace

43.multilevel inheritance using interface

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace multiple_interface {     interface emp_info     {         int EID { get; set; }         string ENAME { get; set; }         DateTime DOJ { get; set; }         int exprince();     }     interface dpt_nm     {         string DPT_NAME { get; set; }     }     class child1 : emp_info, dpt_nm     {         public int eid;         public string nm, dp;         public DateTime dt;         public int EID         {             get { return eid; }             set { eid = value; }         }         public string ENAME         {             get { return nm; }             set { nm = value; }         }         public string DPT_NAME         {             get { return dp; }             set { dp = value; }         }         public DateTime DOJ         {             get { return dt; }             set { dt = value; }         }         public int exprince()         {             Ti

55.java.lang.math class

Image
 

42.static_class and _method

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace static_class_method.cs {     static class demo     {         public static void msg()         {             Console.WriteLine("This is static method of staitc class demo");         }     }     class Program     {         static void Main(string[] args)         {             demo.msg();             Console.Read();         }     } } OUTPUT: This is static method of staitc class demo

40.sealed method, it cannot be overridden.

 /*  If you create a sealed class, it cannot be derived. If you create a sealed method, it cannot be overridden. Local variables can't be sealed. The sealed method in C# cannot be overridden further. It must be used with override keyword in method. */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace sealed_method.cs {     class Base     {         public virtual string display()         {             return "Base class method";         }     }     class Derived : Base     {         public sealed override string display()         {             return "sealed mehtod of Derived class";         }     }     class Program     {         static void Main(string[] args)         {             Derived obj = new Derived();             Console.WriteLine( obj.display());             Console.Read();         }     } } OUTPUT: sealed mehtod of Derived class

41. Partial class : class is divide

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace partial_class.cs {     partial class BCA     {         public void hi()         {             Console.WriteLine("HI...");         }     }     partial class BCA     {         public void hello()         {             Console.WriteLine("Hello...");         }     }     class Program     {         static void Main(string[] args)         {             BCA obj = new BCA();             obj.hi();             obj.hello();             Console.Read();         }     } } OUTPUT: HI... Hello...

39.sealed class can't inherite or override

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace seald_class.cs {     public sealed class classsealed // it can't inheritaed and override     {         int no = 7;         public void display()         {             Console.WriteLine("Vakue of A : " + no);         }     }     class Program     {         static void Main(string[] args)         {             classsealed obj = new classsealed();             obj.display();             Console.Read();         }     } } OUTPUT: Value of A : 7