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 ------------------ | |
| // Abstract class with abstract method | |
| abstract class Animal { | |
| public void canRun() { | |
| System.out.println("Animal can run"); | |
| } | |
| // Abstract method - has no definition | |
| public abstract void canFly(); |
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 Parent { | |
| private int a = 10; | |
| void addTwo() { | |
| a += 2; | |
| } | |
| void showValueOfA() { | |
| System.out.println(a); | |
| } |
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
| public class Commentexecution { | |
| public static void main(String[] args) { | |
| int alpha = 10; | |
| // I'm changing the value of \u000d alpha = 30; | |
| System.out.println("Value of alpha : " + alpha); | |
| } | |
| } |
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 Test { | |
| // Empty scope - equvalent to normal variable initialisation - P2 | |
| { | |
| System.out.println("Empty scope called"); | |
| } | |
| // constructor - P3 | |
| Test() { | |
| System.out.println("Constructor called"); |
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
| def showNames(x,y,z): | |
| print("\n Printing output : ") | |
| print(x) | |
| print(y) | |
| print(z) | |
| listnames = ['medium','vivek','vijayan'] | |
| showNames[listnames[0], listnames[1], listnames[2]] |
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
| def showNames(x,y,z): | |
| print("\n Printing output : ") | |
| print(x) | |
| print(y) | |
| print(z) | |
| listnames = ['medium','vivek','vijayan'] | |
| showNames(* listnames). |
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
| def showNames(x,y,z): | |
| print("\n Printing output : ") | |
| print(x) | |
| print(y) | |
| print(z) | |
| dictnames = {'x':'medium', 'y':'vivek','z':'vijayan'} | |
| showNames(** dictnames) |
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
| package payroll | |
| type Employee struct { | |
| Empid int // public variable as the Empid starts with upper case | |
| empname string // private variable as the empname starts with lowercase | |
| salary int // private variable as the empname starts with lowercase | |
| } | |
| func (emp *Employee) AddEmployeeDetails(name string, salary int) { | |
| emp.SetEmpName(name) |
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
| package main | |
| import ( | |
| "fmt" | |
| "sample/payroll" | |
| ) | |
| func main() { | |
| emp := payroll.Employee{Empid: 10} // or emp.SetEmpid(10) as it is a public variable |
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> | |
| template <int n> | |
| struct factorial | |
| { | |
| enum | |
| { | |
| output = 2 * factorial<n - 1>::output | |
| }; | |
| }; |
OlderNewer