To know more :
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 Animal{ | |
| // Creating the interface inside class; nested interface. | |
| interface Activity{ | |
| public default void move(){ | |
| System.out.println("Animal is moving."); | |
| } | |
| } | |
| } |
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
| #include<iostream> | |
| using namespace std; | |
| int fibonacci(int); | |
| int main(){ | |
| int number; | |
| cout << "Enter how many elements you want to see in Fibonacci Series : "; | |
| cin >> number; |
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
| #include<iostream> | |
| using namespace std; | |
| int factorial(int); | |
| int main(){ | |
| int number, factorialOfNumber; | |
| cout << "Enter a number you want to calculate factorial : "; | |
| cin >> number; |
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
| // Importing File class from Java io package. | |
| // CLA in documentation refers to Command Line Argument. | |
| import java.io.File; | |
| // Creating a class named StringTest. | |
| class StringTest{ | |
| public static void main(String[] args){ | |
| // To prevent any of the exception that may arise, I put the codes under try block. | |
| try{ |
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 java.io.File; | |
| class CountsFile{ | |
| private static int count; // Count variable to count the no of files. | |
| public static void count(){ | |
| count++; // Every time the method is envoked, count increases by 1. | |
| } | |
| public static int getCount(){ | |
| return count; // Getter for count. | |
| } |
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
| // www.github.com/thearjun | |
| class Calculate | |
| { | |
| int num1, num2; | |
| Calculate(int number1, int number2) | |
| { | |
| num1 = number1; | |
| num2 = number2; |
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
| stringOne = str(input("Enter string one : ")) | |
| stringTwo = str(input("Enter string two : ")) | |
| print("\nBefore Swapping\n") | |
| print("String One : %s"%(stringOne)) | |
| print("String Two : %s"%(stringTwo)) | |
| # Pre-Defined Method | |
| # stringOne,stringTwo = stringTwo,stringOne |
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 DecToBin{ | |
| public static void main(String[] args){ | |
| int dec = 64; | |
| int bin=1,rem=0;// I assigned bin to 1 in this revision. | |
| while(dec>1){ // I run the loop while dec is greater than 1 in this revision. | |
| rem=dec%2; | |
| bin=bin*10+rem; | |
| dec=dec/2; | |
| } | |
| System.out.println("In Binary = "+bin); |
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
| #include<iostream> | |
| #include<string> | |
| using namespace std; | |
| class University{ | |
| private: | |
| string uname; | |
| public: | |
| University():uname("unspecified"){} | |
| University(string u):uname(u){} |

