This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// coded by Anuj Jha | |
// | |
#include <stdio.h> | |
#include<ctype.h> | |
int main() { | |
FILE *fp; | |
char vowels[] = {'a','e','i','o','u'}; | |
char alphabets[] = {'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z'}; | |
char digit[] = {'0','1','2','3','4','5','6','7','8','9'}; | |
char spSymbol[] = {'#','!','@','$','^','&','*'}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------------------------------------------------------------------------------------------------- | |
####################################################################################################################### | |
----------------------------------------------------------------------------------------------------------------------- | |
string firstFriend = "Maria"; | |
string secondFriend = "Sage"; | |
Console.WriteLine($"My friends are {firstFriend} and {secondFriend}"); | |
>>My friends are Maria and Sage. | |
----------------------------------------------------------------------------------------------------------------------- | |
####################################################################################################################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//coded by anuj_jha(170303105120) | |
//P2: CDMA for two user and one bit data. | |
import java.util.Scanner; | |
public class cdma { | |
static Scanner input = new Scanner(System.in); | |
public static void main(String[] ar){ | |
System.out.println("Enter Data 1 (1 bit) : "); | |
int data1 = inputData(); | |
System.out.println("Enter code 1 (4 bit) : "); | |
int[] codeArray1 = inputArray(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// coded by Anuj Jha | |
// Caesar Cipher encryption-decryption | |
//caution : avoid special character. | |
import java.util.Scanner; | |
public class CaesarCipher { | |
static int[] encryption(int[] charArray, int key){ | |
for(int i = 0; i < charArray.length;i++){ | |
if(charArray[i] <=90) //for UPPERCASE | |
charArray[i] = ((charArray[i] + key -65) % 26) + 65; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.lang.Thread.sleep; | |
class Player implements Runnable{ | |
private int speed; | |
private String name; | |
private static int coveredDistance=0; | |
Player(String name, int speed){ | |
this.name = name; | |
this.speed = speed; | |
} | |
public void run(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//synchronized block | |
import java.util.Scanner; | |
class Account{ | |
private int balance; | |
Account(int balance){ | |
this.balance = balance; | |
} | |
private boolean isSufficient(int balance){ | |
return (this.balance >= balance); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//default throw our catch | |
public class ExpHand1 { | |
public static void main(String[] a) { | |
try { | |
System.out.println("INSIDE TRY l1"); | |
String s = null; | |
int len = s.length();//null pointer exception | |
// int tmp = 5 / 0;//arithmetic exception | |
System.out.println("INSIDE TRY l3");//not executed | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//fields are implicitly : public & static & final. | |
//methods are implicitly : public & abstract. | |
//since fields are abstract interface doesn't support constructor. | |
//>>class C2 extends C1 implements I3<< | |
//Above syntax also possible. | |
interface I1{ | |
void f1(); | |
} | |
interface I2{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// data field cant be abstract mut method does. | |
//data field - protected/public. | |
//methods - public/default/protected | |
abstract class Person{ | |
protected String name; | |
protected int age; | |
abstract public void setName(String name); | |
abstract public void setAge(int age); | |
abstract public String getName(); | |
abstract public int getAge(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main{ | |
public static void main(String[] a){ | |
Student s1 = new Student(); | |
s1.setRollNumber(1); | |
s1.setName("Anuj"); | |
s1.setAge(21); | |
System.out.println("RollNUmber: "+s1.getRollNumber()+"\tName : "+s1.getName()+"\tAge : "+s1.getAge()); | |
} | |
} |
NewerOlder