Skip to content

Instantly share code, notes, and snippets.

View vivek-vijayan's full-sized avatar
✔️
Focusing on developing new model for ML

Vivek Vijayan vivek-vijayan

✔️
Focusing on developing new model for ML
View GitHub Profile
@vivek-vijayan
vivek-vijayan / Main.java
Last active August 8, 2022 10:33
Abstract class and method program
// --------- 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();
class Parent {
private int a = 10;
void addTwo() {
a += 2;
}
void showValueOfA() {
System.out.println(a);
}
@vivek-vijayan
vivek-vijayan / Commentexecution.java
Created August 8, 2022 10:45
Executable comments in Java
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);
}
}
@vivek-vijayan
vivek-vijayan / PrecedenceCheck.java
Created August 26, 2022 12:18
Precedence checking program in Java
class Test {
// Empty scope - equvalent to normal variable initialisation - P2
{
System.out.println("Empty scope called");
}
// constructor - P3
Test() {
System.out.println("Constructor called");
@vivek-vijayan
vivek-vijayan / main.py
Last active August 27, 2022 08:24
Python to explain star operator
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]]
@vivek-vijayan
vivek-vijayan / main_with_star.py
Created August 27, 2022 08:29
main_with_star operator
def showNames(x,y,z):
print("\n Printing output : ")
print(x)
print(y)
print(z)
listnames = ['medium','vivek','vijayan']
showNames(* listnames).
@vivek-vijayan
vivek-vijayan / main_with_2_star.py
Created August 27, 2022 08:35
Double star operator
def showNames(x,y,z):
print("\n Printing output : ")
print(x)
print(y)
print(z)
dictnames = {'x':'medium', 'y':'vivek','z':'vijayan'}
showNames(** dictnames)
@vivek-vijayan
vivek-vijayan / payroll.go
Last active August 28, 2022 17:39
Go program for payroll
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)
@vivek-vijayan
vivek-vijayan / main.go
Last active August 28, 2022 17:44
Go programming for main
package main
import (
"fmt"
"sample/payroll"
)
func main() {
emp := payroll.Employee{Empid: 10} // or emp.SetEmpid(10) as it is a public variable
@vivek-vijayan
vivek-vijayan / metaprogramming.cpp
Created August 30, 2022 17:45
C++ programming for Meta
#include <iostream>
template <int n>
struct factorial
{
enum
{
output = 2 * factorial<n - 1>::output
};
};