This file contains 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
Table Name: EMP | |
Columns: | |
EMPNO [numeric](4, 0) NOT NULL PRIMARY KEY, | |
ENAME [varchar](10) NULL, | |
JOB [varchar](10) NULL, | |
MGR [numeric](4, 0) NULL, | |
HIREDATE [date] NULL, | |
SAL [numeric](7, 2) NULL, | |
COMM [numeric](7, 2) NULL, |
This file contains 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 ArrayDemo1 { | |
public static void main(String[] args) { | |
int[][] arr2D = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 9, 5, 3 } }; | |
int[] result = getColumn(arr2D,1); | |
System.out.println(result.length); | |
for(int data: result){ | |
System.out.println(data); | |
} | |
} |
This file contains 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
/** | |
* About switch case | |
* Program to get weekday name. Initialize value with weekday number | |
* 0 - Sunday | |
* */ | |
public class SwitchCaseDemoWeekDayName { | |
public static void main(String[] args) { | |
byte weekDayNum=0; | |
switch (weekDayNum){ |
This file contains 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
/** | |
* To determine particular character is vowel or not. | |
* Switch case example | |
* */ | |
public class SwitchCaseDemoVowel { | |
public static void main(String[] args) { | |
char ch='e'; | |
//Converts the character to uppercase | |
ch = Character.toUpperCase(ch); |
This file contains 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
/*** | |
* American paper currency come in seven denominations: $1, $2, $5, $10, $20, $50, and $100. | |
* Write a program that display various dollar bills required for particular amount | |
*/ | |
public class DollarBillsDemo { | |
public static void main(String[] args) { | |
int dollarAmount = 1285; | |
int d1,d2,d5,d10,d20,d50, d100, rem; | |
d100 = dollarAmount/100; | |
rem = dollarAmount%100; |
This file contains 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
/** | |
* To learn about variable number of arguments to the function | |
* The three dots ( ... ) are used in a function's declaration as a parameter. | |
* These dots allow zero to multiple arguments to be passed when the function is called. | |
* The three dots are also known as var args . | |
* Varargs is a short name for variable arguments. | |
* */ | |
public class VariableArgumentsDemo { | |
public static void main(String[] args) { |
This file contains 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 ProfitLossDemo { | |
public static void main(String[] args) { | |
double costPrice, salesPrice,profitAmt,lossAmt, profitPercentage, lossPercentage; | |
costPrice=50; | |
salesPrice=50; | |
if(costPrice>salesPrice){ | |
lossAmt= costPrice-salesPrice; | |
lossPercentage=100*lossAmt/costPrice; | |
System.out.println("Loss in amount "+ lossAmt); | |
System.out.println("Loss in % " + lossPercentage); |
This file contains 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
/** | |
* To determine that particular year is a leap year or not | |
* Note: | |
* A year is a leap year if the following conditions are satisfied: | |
* The year is multiple of 400. | |
* The year is multiple of 4 and not multiple of 100. | |
* According to these rules, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300, and 2500 are not leap years. | |
* References: | |
* https://www.timeanddate.com/date/leapyear.html | |
* https://www.wikihow.com/Calculate-Leap-Years |
This file contains 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
/** | |
* Example of method overloading | |
*Create a class name MyTime as follows: | |
* | |
* List of data member | |
* 1. hours | |
* 2. minutes | |
* 3. seconds | |
* | |
* List of methods |
This file contains 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 DetermineOutputDemo { | |
public static void main(String[] args) { | |
outputDemo7(); | |
} | |
static void outputDemo1(){ | |
//Output x is :2 | |
int x; | |
x = 3*4%5; | |
System.out.println("x is :" + x); | |
} |
OlderNewer