├── .classpath ├── .gitattributes ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs └── org.eclipse.jdt.core.prefs ├── ReplitSolutions ├── _0_001_Basics_HelloWorld1.java ├── _0_002_Basics_HelloWorld2.java ├── _0_003_Basics_PrintName.java ├── _0_004_Basics_PrintNumbers.java ├── _0_005_Basics_FixPrint.java ├── _0_006_Basics_Cool.java ├── _0_010_Basics_PrintVariable1.java ├── _0_011_Basics_PrintVariable2.java ├── _0_012_Basics_PrintVariable3.java ├── _0_013_Basics_PrintVariable4.java ├── _0_014_Basics_PrintVariable5.java ├── _0_016_Basics_PrintVariable6.java ├── _0_017_Basics_PrintVariable7.java ├── _1_001_Variables_Primitives1.java ├── _1_002_Variables_Primitives2.java ├── _1_003_Variables_ShoppingList1.java ├── _1_004_Variables_Time.java ├── _1_005_Variables_PhoneNumber.java ├── _1_006_Variables_AddNumbers.java ├── _1_007_Variables_PatientInformation.java ├── _1_010_Variables_SecondsConverter.java ├── _1_011_Variables_CaffeineOverDose.java ├── _1_012_Variables_SchoolGrades.java ├── _2_001_Statements_GreaterNumber.java ├── _2_002_Statements_NumsGreaterEqual.java ├── _2_003_Statements_OddOrEven.java ├── _2_004_Statements_QuizQuestion.java ├── _2_005_Statements_ConditionalStatementPractice3.java ├── _2_006_Statements_VendingMachine.java ├── _2_007_Statements_GiftCard.java ├── _2_008_Statements_AndroidVersions.java ├── _2_008_Statements_Citizens.java ├── _2_008_Statements_PositiveNegativeOrZero.java ├── _2_009_Statements_VideoGameCoupons.java ├── _2_011_Statements_ApartmentLeasing1.java ├── _2_014_Statements_FindMidNumber.java ├── _2_016_Statements_BlackjackKeepHand.java ├── _2_017_Statements_HappyValleySchoolSystem.java ├── _2_018_Statements_VehicleRecall.java ├── _2_021_Statements_RealEstateCalculator.java ├── _2_023_Statements_ThreeNumsBigger.java ├── _2_024_Statements_IfStatementGrades.java ├── _2_025_Statements_BurgerOrChicken.java ├── _2_030_Statements_HttpStatusCodes.java ├── _2_031_Statements_LaptopConfigurator.java ├── _2_032_Statements_SwitchChar.java ├── _2_033_Statements_WeekDays.java ├── _2_034_Statements_Calendar.java ├── _2_035_Statements_TernaryOperator1.java ├── _2_036_Statements_TernaryOperator2.java ├── _2_037_Statements_ConsoleMenu.java ├── _3_001_String_VerifyContains.java ├── _3_002_String_FindAUser.java ├── _3_003_String_FindTheLength.java ├── _3_004_String_PrintFirstCharacter.java ├── _3_005_String_PrintLastCharacter.java ├── _3_006_String_PrintFirstAndLastLetters.java ├── _3_007_String_MiddleOne.java ├── _3_008_String_DuplicateIt.java ├── _3_009_String_MergeThem.java ├── _3_010_String_ReverseIt.java ├── _3_011_String_Words.java ├── _3_012_String_PrintHalfTwice.java ├── _3_013_String_PrintTheLongestWord.java ├── _3_015_String_StringNoEnd.java ├── _3_016_String_MiddleThree.java ├── _3_017_String_Alejandro1.java ├── _3_018_String_Alejandro2.java ├── _3_019_String_Email1.java ├── _3_020_String_Email2.java ├── _3_021_String_CarInsuranceQuote.java ├── _3_022_String_SMSMessage.java ├── _3_023_String_Without_Xx.java ├── _3_027_String_HasAJava.java ├── _3_028_String_GetSandwich.java ├── _3_029_String_PrefixAgain.java ├── _4_001_Loops_ShoppingList2.java ├── _4_002_Loops_Party.java ├── _4_003_Loops_ZombieAttack1.java ├── _4_004_Loops_CatsAndDogs.java ├── _4_005_Loops_PrintLettersCombinations.java ├── _4_006_Loops_Factorial.java ├── _4_007_Loops_CountHi.java ├── _4_008_Loops_CountJava.java ├── _4_009_Loops_CountTriples.java ├── _4_010_Loops_EachLetter.java ├── _4_011_Loops_EqualsJavaPython.java ├── _4_012_Loops_PrintNTimes.java ├── _4_013_Loops_PrintEvenFrom80To20.java ├── _4_014_Loops_PrintLetters.java ├── _4_015_Loops_PrintTriangle.java ├── _4_016_Loops_PrintVowels.java ├── _4_017_Loops_RepeatSeparator.java ├── _4_018_Loops_UtopianTree.java ├── _5_002_Arrays_FrontPiece.java ├── _5_003_Arrays_AverageTemperature.java ├── _5_004_Arrays_CountEvens.java ├── _5_005_Arrays_FindMax.java ├── _5_006_Arrays_FindNonDuplicate.java ├── _5_007_Arrays_FindSum.java ├── _5_013_Arrays_FindingMaxLengthInStringArray.java ├── _5_014_Arrays_PrintFirstAndLastChar2.java ├── _5_015_Arrays_PrintShortestWord.java ├── _5_023_Arrays_SplitEmail.java ├── _5_024_Arrays_SplitSentence.java ├── _6_001_Methods_HelloWorld.java ├── _6_002_Methods_PicturePrinterForFunNoTestCases.java ├── _6_002_Methods_SimpleCalculator.java ├── _6_002_Methods_SimpleCalculator48.java ├── _6_003_Methods_FindCube.java ├── _6_003_Methods_FindCube43.java ├── _6_004_Methods_Signum.java ├── _6_008_Methods_PrintNext3Numbers.java ├── _6_008_Methods_SplitPersonInfo.java ├── _6_009_Methods_FibonacciNumbers.java ├── _6_009_Methods_PalindromeNumber.java ├── _6_010_Methods_PopulateArray.java ├── _6_010_Methods_SwitchElements.java ├── _6_011_Methods_AddToArray.java ├── _6_014_Methods_PrintUniqueNumbers.java ├── _6_019_Methods_MethodsWithReturnMax.java ├── _6_020_Methods_MethodsWithReturnIsEven.java ├── _6_021_Methods_MethodsWithReturnProfitOrLoss.java ├── _6_022_Methods_MethodsWithReturnHamletLogic.java ├── _6_023_Methods_MethodsWithReturnWaterTax.java ├── _6_024_Methods_MethodsWithReturn3Locks.java ├── _6_025_Methods_MethodsWithReturnValidateTask.java ├── _6_026_Methods_MethodsWithReturnSimpleRoomBooking.java ├── _6_027_Methods_MethodsWithReturnThunderBlazz.java ├── _6_028_Methods_MethodsWithStringMergeThem.java ├── _6_029_Methods_MethodsWithStringRemoveDuplicates.java ├── _6_031_Methods_MethodsWithStringWordCount.java ├── _6_032_Methods_MethodsWithStringCleanString.java ├── _6_033_Methods_MethodsWithStringLimitString.java ├── _6_034_Methods_MethodsWithStringAt3rdChar.java ├── _6_035_Methods_MethodsWithStringBiggerString.java ├── _6_036_Methods_MethodsWithStringRemoveFirstChar.java ├── _6_037_Methods_MethodsWithStringLameDB.java ├── _6_038_Methods_MethodsWithStringCover.java ├── _6_039_Methods_MethodsWithStringReverseString.java ├── _6_040_Methods_MethodsWithStringFindErrorString.java ├── _6_042_Methods_MethodsWithStringCountLetters.java ├── _6_043_Methods_Palindrome.java ├── _6_045_Methods_Anagram.java ├── _6_046_Methods_CopyCertainValuesArray.java ├── _6_047_Methods_MethodOverloading1.java ├── _6_048_CheckIfNumberIsPalindrome ├── _6_048_Methods_MethodsWithArraysMergeArrays.java ├── _6_049_Methods_MethodsWithArraysTicTacToe.java ├── _6_050_Methods_MethodsWithArrays3GetDuplicates.java ├── _6_051_Methods_MethodsWithArraysAddElements.java ├── _6_052_Methods_ReverseLetters.java ├── _6_053_Methods_StringExtractNumberFromString.java ├── _7_002_ArrayList_Add.java ├── _7_003_ArrayList_Set.java ├── _7_006_ArrayList_Remove.java ├── _7_007_ArrayList_AddInsert.java ├── _7_007_ArrayList_RemoveAll.java ├── _7_008_ArrayList_CombineAll.java ├── _7_009_ArrayList_CombineArrays.java ├── _7_010_ArrayList_AppendPosSum.java ├── _7_011_ArrayList_TimesTwo.java ├── _7_012_ArrayList_RepeatAll.java └── assignment9 │ ├── Question01.java │ ├── Question02.java │ ├── Question03.java │ ├── Question04.java │ ├── Question05.java │ ├── Question06.java │ ├── Question07.java │ ├── Question08.java │ ├── Question09.java │ ├── Question10.java │ ├── Question11.java │ ├── Question12.java │ ├── Question13.java │ ├── Question14.java │ └── Question15.java ├── live_review_sections ├── week1 │ ├── CarInfo.java │ ├── EmployeeInfo.java │ ├── PrimitivesReview.java │ ├── PrintStatements.java │ ├── ReadMe.md │ ├── ScanerExample.java │ ├── TellMeAboutYourself.java │ ├── Timer.java │ └── _Shapes.java ├── week10 │ ├── AmazonInc.java │ ├── Developer.java │ ├── Employee.java │ ├── Notes.java │ ├── SupportPersonel.java │ └── Tester.java ├── week11 │ ├── FinalKeyword.java │ ├── car_examples │ │ ├── BMW.java │ │ ├── Car.java │ │ ├── ParkingLot.java │ │ ├── Tesla.java │ │ └── Toyota.java │ └── exercise_example │ │ ├── AtTheGym.java │ │ ├── Exercise.java │ │ ├── FreeWeight.java │ │ ├── Lifting.java │ │ ├── Running.java │ │ └── Swimming.java ├── week12 │ ├── interface_demo │ │ ├── ChromeDriver.java │ │ ├── FirefoxDriver.java │ │ ├── UIAutomationTest.java │ │ └── WebDriver.java │ └── polymorphism_demo │ │ ├── Father.java │ │ ├── SuperManTest.java │ │ ├── Superman.java │ │ └── Worker.java ├── week13 │ ├── FinallyBlock.java │ ├── MultipleCatchBlock.java │ ├── StringIndexProblem.java │ ├── ThrowingExceptions.java │ ├── TypesOfExceptions.java │ └── customExceptions │ │ ├── BreakTimeException.java │ │ └── CustomExceptionTest.java ├── week14 │ ├── IteratorExample.java │ ├── LinkedListExample.java │ ├── ListExamples.java │ ├── ListIsEqualToSetExample.java │ ├── ListOfMapExample.java │ └── SetExample.java ├── week2 │ ├── AddNumbersfromReplit.java │ ├── ArithmeticOperatorsReview.java │ ├── AssignmentOperatorsReview.java │ ├── DifferenceBetweenAnd_BitwiseAnd.java │ ├── DivisionAndRemainderPractice.java │ ├── EvenorOdd.java │ ├── Grader.java │ ├── MonthCalculator.java │ ├── ReadMe.md │ ├── RelationalOperators.java │ ├── SwitchExampleOrLogic.java │ ├── SwitchInTestersLife.java │ └── UnaryReview.java ├── week3 │ ├── Assignment5_Q_4.java │ ├── BasicLoopExamples.java │ ├── ContinueAndBreakExample.java │ ├── CustomMethod2.java │ ├── CustomMethod3.java │ ├── CustomMethod4.java │ ├── CustomMethods1.java │ ├── Finra.java │ ├── MaxAndMinWithLoop.java │ ├── NestedLoopExample.java │ ├── PrintAllLetters.java │ ├── TernaryExample.java │ ├── Week3Notes.txt │ └── WhileLoopExamples.java ├── week4 │ ├── AmazonTest.java │ ├── AmazonTest_2.java │ ├── Art.java │ ├── Bank.java │ ├── BankAccount.java │ ├── Calculator.java │ ├── CalculatorOverLoading.java │ ├── Circle.java │ ├── CircleTest.java │ ├── CompanyComparions.java │ ├── GarbageExample.java │ ├── ImportExample.java │ ├── LocalVsInstance.java │ ├── LocalVsInstanceTest.java │ ├── NextVsNextLine.java │ ├── NotesForWeek4.java │ ├── Salary.java │ ├── SalaryTest.java │ ├── ScrumTeam.java │ └── TestCase.java ├── week5 │ ├── Notes.txt │ ├── S01_StringPractice.java │ ├── S02_StringPractice.java │ ├── S03_StringMethodsPractice.java │ ├── S04_IndexOfExample.java │ ├── S05_StringReverse.java │ ├── S06_StringCustomMethods.java │ ├── S07_ExamplesWithCustomClassMethods.java │ ├── S08_CustomStringMethodsStaticWay.java │ └── S09_FrequencyOfWord.java ├── week6 │ ├── A01_ArraysFundementals.java │ ├── A02_ArraysExample.java │ ├── A03_ArrayLoopWithConditions.java │ ├── A04_HTML_Satus_Codes.java │ ├── A05_MallShoppingAppTest.java │ ├── A06_FindMax.java │ ├── A07_SentenceSplit.java │ ├── A08_ReverseArray.java │ ├── A09_AddElementToArray.java │ ├── A10_MultiDimensionalArrays.java │ ├── A11_BiggestIn2DArray.java │ ├── A12_MakeEnds.java │ └── QuizQ4.java ├── week7 │ ├── NotesWeek7 │ ├── Products.java │ ├── R01_CharArray.java │ ├── R02_CharArray2.java │ ├── R03_IsAnagram.java │ ├── R04_WrapperClassPractice.java │ ├── R05_WrapperClassCharacters.java │ ├── R06_WrapperClassCharacters.java │ ├── R07_Arrays2DMaxMinValue.java │ ├── R08_ArrayListPractice.java │ ├── R09_ArrayListExamples.java │ ├── R10_ArrayListMethods.java │ └── R11_ArrayListWithObjects.java ├── week8 │ ├── AmazonTest.java │ ├── ConstructorsPractice.java │ ├── Credentials.java │ ├── Employee.java │ ├── Item.java │ ├── Login.java │ ├── Microsoft.java │ ├── R01_ArrayListPractice.java │ ├── R02_CollectionsUtility.java │ ├── notes.txt │ └── testEnvironment │ │ ├── Browser.java │ │ ├── OS.java │ │ ├── TestEnvironment.java │ │ └── Tests.java └── week9 │ ├── StaticMethods.java │ ├── StaticTest.java │ ├── inheritance │ ├── AudioBook.java │ ├── Book.java │ ├── BookObjects.java │ └── Ebook.java │ └── notes.txt └── src ├── day01_hello_world └── Main.java ├── day02_printing_comments ├── Commenting.java ├── Concatenation.java ├── EscapeSequences.java ├── HelloWorld.java ├── PrintlnVSprint.java ├── Task1_triangle.java ├── Task2_gasReceipt.java ├── Task3_printExercise.java └── Task4_escapeSequence.java ├── day03_variables_dataTypes ├── ConstantVariables.java ├── CreatingVariables.java ├── PrimitiveVariables.java └── VariableDeclaration.java ├── day04_arithmetic_operators ├── AdditionConcat.java ├── ArtihmeticOperators.java ├── Contribution.java ├── Discount.java ├── Task13_FindSum.java ├── Task14_ConvertFahrenheitToCelcius.java ├── Task15_MileConverter.java ├── Task16_AreaOfCircle.java ├── Task17_AverageNumbers.java ├── Task8_VariablePractice.java └── Wages.java ├── day05_unary_assignment_relational_operators ├── AssignmentOperators.java ├── MixedInteger.java ├── RelationalOperators.java ├── Task18_PrepostDecrementIncrement.java ├── Task19_IncrementDecrement.java ├── Task20_IncrementDecrement.java ├── Task21_IncrementDecrement.java ├── Task22_RelationalOperator.java ├── TypeCasting.java └── UnaryOperators.java ├── day06_logical_operators ├── LogicalOperators.java ├── OperatorPrecedence.java └── Task23_Operators.java ├── day07_control_flow_statements ├── IfElseStatement.java ├── IfStatements.java ├── SmallTasks.java ├── Task24_EligibleToVote.java ├── Task25_GreatestNumber.java ├── Task26_EqualNumbers.java ├── Task27_GreetingHours.java └── Task28_RevenueCalculator.java ├── day08_control_flow_statements_2 ├── IfElseIfElse.java ├── NestedIfStatement.java ├── SmallTasks2.java ├── SwitchCaseStatement.java ├── Task29_BiggerNumber.java ├── Task30_EvenOddNumber.java ├── Task31_TriangleAngles.java ├── Task32_LargestNumber.java ├── Task33_Grading.java ├── Task34_AverageGrading.java ├── Task35_FindGreatestNested.java └── Task36_Calculator.java ├── day09_controlFlowStatements_3 ├── IfElseRules.java ├── ORLogicWithSwitch.java ├── SwitchCaseRules.java ├── task37_LaptopModels.java ├── task38_DaySelector.java └── task39_TrafficLightSelector.java ├── day10_controlFlowStatements_4 ├── ForLoop.java ├── task40_EvenNumbers.java ├── task41_OddNumbers.java ├── task42_SumOfEvenOddNumbers.java ├── task43_PrintTable.java ├── task44_SpeedConverter.java ├── task45_RepeatedBiggerNumber.java ├── task46_MultiplicationTable.java └── ternaryOperator.java ├── day11_controlFlowStatements_5 ├── DoWhileLoop.java ├── ForLoopRules.java ├── NestedForLoop.java ├── NestedForLoop2.java ├── WhileLoop.java ├── task47_Pattern.java ├── task48_Pattern.java ├── task49_pattern.java ├── task50_Pattern.java ├── task52_whileLoop.java └── task53_sumOfEvenNumbers.java ├── day12_controlFlowStatements_6 ├── BranchingStatements.java ├── BreakContinue.java └── LabeledStatements.java ├── day13_methods_Part1 ├── CredirCardMethod.java ├── DeepAndDeeper.java ├── GoogleSearch.java ├── LoopCallMethod.java ├── PassArg.java ├── PassMultipleArguments.java ├── SimpleMethod.java ├── StudentMethod.java ├── task56_convertKM.java ├── task57_sumOfNumbers.java ├── task58_greaterNumber.java ├── task59_PayCalculator.java ├── task60_calculator.java └── task61_AgeCalculator.java ├── day14_methods_Part2 ├── Lab1_StringTimes.java ├── Lab2_Love6.java ├── Lab3_SpecialEleven.java ├── Lab4_DeerPlay.java ├── Lab5_CaughtSpeeding.java ├── Lab6_CigarParty.java ├── ValueReturn.java └── task66_DistanceTraveled.java ├── day15_methods_Part3 ├── MethodOverloading.java ├── MethodOverloading2.java ├── assignment1_SwapValue.java ├── assignment3_Fibonacci.java ├── task67_LastDigit.java ├── task68_Retirement.java ├── task69_Prime.java ├── task70_HighScore.java └── task71_MethodOverloading.java ├── day16_classObejcts ├── Bestbuy.java ├── Car.java ├── CarObjects.java ├── CellPhone.java ├── Contact.java ├── Dog.java ├── DogObjects.java └── Employee.java ├── day17_classObjects_Part2 ├── BMW.java ├── BankAccount.java ├── CapitalOne.java └── CarObjects.java ├── day18_readingUserInput ├── ChangeMaker.java ├── UserInput.java ├── UserInput2.java ├── UserInput3.java ├── task72_SumNumbers.java ├── task73_guessingGame.java └── task74_positiveNumberTotal.java ├── day19_stringManipulation_part1 ├── String_CharAt.java ├── String_Concat.java ├── String_Contains.java ├── String_Length.java ├── task75_TotalCharacters.java ├── task76_PrintingEachCharacter.java ├── task77_EmoiProgram.java ├── task78_CountHowMany.java └── task79_PrintingWovels.java ├── day20_stringManipulation_part2 ├── String_Equals.java ├── String_IndexOf.java ├── String_IndexOf2.java ├── String_Replace.java ├── String_Replace2.java ├── task80_CheckString.java ├── task81_TimeStamp.java └── task82_Login.java ├── day21_stringManipulation_part3 ├── String_SubString.java └── String_Trim.java ├── day22_stringManipulation_Lab ├── Question_1.java ├── Question_2.java ├── Question_3.java ├── Question_4.java ├── Question_5.java ├── Question_6.java ├── Question_7.java ├── Question_8.java ├── Question_9.java ├── Quetion_10.java ├── String_IsEmpty.java └── String_StartsEndsWith.java ├── day23_stringManipulationLab_randomClasss ├── MathTutor.java ├── Question_11.java ├── Question_12.java ├── Question_13.java ├── Question_14.java ├── Question_15.java ├── Question_17_Palindrome.java ├── RandomNumbers.java ├── task83_RollDice.java ├── task84_CoinToss.java └── task85_DiceGame.java ├── day24_arrays_part1 ├── Array.java ├── ArrayCreation.java ├── task86_MonthArray.java ├── task87_DayArray.java ├── task88_CarPrice.java ├── task89_ShoppingList.java └── task90_FindingCar.java ├── day25_arrays_part2 ├── ForEachLoop.java ├── PassArray.java ├── PassElements.java ├── PayArray.java ├── ReturnArray.java ├── SameArray.java ├── task91_RandomArrayNumbers.java └── task92_TableArray.java ├── day26_arrays_part3 ├── Array2D.java ├── MethodArray.java ├── MethodArrays2.java ├── StringMan_Arrays.java ├── task93_HowManyWords.java └── task94_SearchResult.java ├── day27_arrays_part4 ├── ArrayClass.java ├── Lab4_Question1.java ├── Lab4_Question2.java ├── Lab4_Question3.java ├── Length.java ├── Loop2DArray.java ├── Pizza_2DArray.java ├── RaggedArray.java ├── Teams.java └── task95_ScoreCalc.java ├── day28_arrays_Lab ├── Lab4_Question10.java ├── Lab4_Question11.java ├── Lab4_Question12.java ├── Lab4_Question13.java ├── Lab4_Question14.java ├── Lab4_Question15.java ├── Lab4_Question4.java ├── Lab4_Question5.java ├── Lab4_Question6.java ├── Lab4_Question7.java ├── Lab4_Question8.java └── Lab4_Question9.java ├── day29_arrays_Lab ├── Lab4_Question16.java ├── Lab4_Question17.java ├── Lab4_Question18.java ├── Lab4_Question19.java ├── Lab4_Question20.java ├── Lab4_Question21.java ├── Lab4_Question22.java ├── Lab4_Question23.java ├── Lab4_Question24.java └── Lab4_Question29.java ├── day30_wrapperClass ├── Boxing.java ├── CommandLineArgument.java ├── MathClass.java ├── ParsingValues.java ├── VarArgs.java ├── WrapperClass.java ├── WrapperClassMethods.java ├── task96_ConvertingTemp.java └── task97_filterString.java ├── day31_arrayList ├── AddAll.java ├── ArrayListExample.java ├── ArrayListIntro.java ├── Cities.java ├── ContainsMethod.java ├── RemoveInteger.java ├── ShoppingList.java └── task98.java ├── day32_arrayList_part2 ├── CustomMethods.java ├── EqualMethod.java ├── GroceryList.java ├── GroceryListMain.java └── RemoveAll.java ├── day33_ClassObjects_Constructors ├── BankAccount.java ├── BankAccountTest.java ├── Car.java ├── CarTest.java ├── Mouse.java ├── MouseTest.java ├── Rectangle.java ├── RectangleTest.java ├── Student.java └── StudentTest.java ├── day34_Constructors ├── Apple.java ├── AppleTest.java ├── Dice.java ├── DiceTest.java ├── Light.java └── LigthTest.java ├── day35_encapsulation ├── Calculator.java ├── Carpet.java ├── CarpetTest.java ├── Employee.java ├── EmployeeTest.java ├── Floor.java ├── PerseonTest.java ├── Person.java ├── Printer.java ├── PrinterTest.java ├── RoulettePocket.java └── RoulettePocketTest.java ├── day36_staticClassMembers ├── ABC.java ├── ABCTest.java ├── AllBlocks.java ├── AllBlocksTest.java ├── Calculator.java ├── CalculatorTest.java ├── Campus.java ├── CampusTest.java ├── Car.java ├── Countable.java ├── CountableTest.java ├── Dinner.java ├── DinnerTest.java ├── StaticImport.java ├── StaticMethods.java ├── Student.java └── StudentTest.java ├── day37_inheritance ├── Company.java ├── Employee.java ├── FinalExam.java ├── FinalExamTest.java ├── GradeActivity.java ├── Person.java ├── School.java └── Student.java ├── day38_inheritance_part2 ├── Animal.java ├── Car.java ├── CarTest.java ├── CompanyTest.java ├── ConstructorTest.java ├── Contractor.java ├── Dog.java ├── DogTest.java ├── Employee.java ├── FullTimeEmployee.java ├── Person.java ├── StaticSub.java ├── StaticSuper.java ├── StaticTest.java ├── Student.java ├── SubClass.java ├── SuperClass.java └── Vehicle.java ├── day39_inheritance_review ├── Car.java ├── Toyota.java ├── ToyotaTest.java └── Vehicle.java ├── day40_accessmodifiers_final ├── Car.java ├── CarTest.java ├── Child.java ├── FinalArray.java ├── FinalArrayList.java ├── FinalMethods.java ├── FinalVariables.java ├── Kangaroo.java ├── KangarooTest.java ├── Marsupial.java ├── MethodHidingTest.java ├── Mouse.java ├── Parent.java ├── Rodent.java ├── TestMouse.java └── TestParentChild.java ├── day40_accessmodifiers_final_2 ├── Car2.java └── CarTest.java ├── day41_abstract_class ├── Animal.java ├── Bird.java ├── Dog.java └── Parrot.java ├── day42_interface ├── Car.java ├── Electric.java ├── ElectricCar.java ├── ElectricCarTest.java ├── ElectricTruck.java ├── Ford.java ├── SelfDriving.java ├── Tesla.java ├── Tesla2.java ├── TeslaSemi.java ├── TeslaTruck.java └── Vehicle.java ├── day43_polymorphism ├── Circle.java ├── InstanceOf.java ├── Shape.java ├── ShapesArray.java ├── Square.java ├── TestAnimal.java ├── TestShape.java └── Triangle.java ├── day44_oopreview ├── callcenter │ ├── CallCnter.java │ ├── MessagingApp.java │ ├── ScreenSharable.java │ ├── VideoCallable.java │ ├── VideoMessagingApp.java │ ├── VoiceCallable.java │ ├── WhatApp2.java │ └── WhatsApp.java └── shapes │ ├── Diamond.java │ ├── Shape.java │ ├── ShapeActions.java │ ├── ShapeManager.java │ ├── ShapeTest.java │ ├── Square.java │ └── Triangle.java ├── day45_exceptionHandling ├── BadArray.java ├── CheckedVSUncheckedException.java ├── MultiCatch.java ├── Nullpointer.java ├── OrCatchBlock.java ├── Runtimeerror.java ├── ThrowAndThrows.java ├── TryCatch.java ├── TryCatchFinally.java └── TyCatch2.java ├── day46_collection_part1 ├── ArrayVSArrayList.java ├── LinkedListExample.java ├── Product.java ├── SortingList.java └── VectorExample.java ├── day47_collection_part2 ├── LoopArrayList.java ├── LoopSet.java ├── LoopWithIterator.java ├── QueueExample.java ├── SetExample.java └── StackExample.java └── day48_collection_part3 ├── HashSetOfProducts.java ├── ListOfMaps.java ├── LoopMap.java └── MapExample.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | bin 3 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | JavaProgramming_EU7 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//live_review_sections/week2/DivisionAndRemainderPractice.java=UTF-8 3 | -------------------------------------------------------------------------------- /ReplitSolutions/_0_001_Basics_HelloWorld1.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | //Write a statement that prints Hello world to the screen. 4 | //Output must exactly match the requirement 5 | public class _0_001_Basics_HelloWorld1 { 6 | public static void main(String[] args) { 7 | 8 | System.out.println("Hello world"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ReplitSolutions/_0_002_Basics_HelloWorld2.java: -------------------------------------------------------------------------------- 1 | //Write a complete main method that prints Hello world to the screen. 2 | public class _0_002_Basics_HelloWorld2 { 3 | public static void main(String[] args) { 4 | System.out.print("**`Hello world`**"); 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ReplitSolutions/_0_003_Basics_PrintName.java: -------------------------------------------------------------------------------- 1 | //Suppose your name was Alan Turing. 2 | // Write a main method and a statement that would print your last name, 3 | // followed by a comma, followed by a space and your first name. 4 | public class _0_003_Basics_PrintName { 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Turing, Alan"); 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ReplitSolutions/_0_004_Basics_PrintNumbers.java: -------------------------------------------------------------------------------- 1 | //Write multiple print statements that will print from 1 to 10 in separate lines. 2 | // 3 | // 1 2 3 4 5 6 7 8 9 10 4 | public class _0_004_Basics_PrintNumbers { 5 | public static void main(String[] args) { 6 | 7 | System.out.println("\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10"); 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ReplitSolutions/_0_005_Basics_FixPrint.java: -------------------------------------------------------------------------------- 1 | //Rearrange the following code so that 2 | // it forms a correct program that prints out the letter Q 3 | public class _0_005_Basics_FixPrint { 4 | public static void main(String[] args) { 5 | 6 | System.out.print("Q"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ReplitSolutions/_0_006_Basics_Cool.java: -------------------------------------------------------------------------------- 1 | //Write a program that displays: I think being a programmer is cool 2 | 3 | public class _0_006_Basics_Cool { 4 | public static void main(String[] args) { 5 | 6 | System.out.println("I think being a programmer is cool"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ReplitSolutions/_0_010_Basics_PrintVariable1.java: -------------------------------------------------------------------------------- 1 | //Given an integer variable count write a statement that displays the value 2 | 3 | public class _0_010_Basics_PrintVariable1 { 4 | public static void main(String[] args) { 5 | //do not change 6 | int count = 100; 7 | 8 | System.out.println(count); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ReplitSolutions/_0_011_Basics_PrintVariable2.java: -------------------------------------------------------------------------------- 1 | //Given a String variable message write a statement to disply its value 2 | 3 | public class _0_011_Basics_PrintVariable2 { 4 | public static void main(String[] args) { 5 | //do not change 6 | String message = "I am a Cybertek school student."; 7 | 8 | System.out.println(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ReplitSolutions/_1_001_Variables_Primitives1.java: -------------------------------------------------------------------------------- 1 | //Declare an integer variable named degreesCelsius but do not assign any value 2 | // 3 | // Nothing else. Yes, its that simple! 4 | 5 | public class _1_001_Variables_Primitives1 { 6 | public static void main(String[] args) { 7 | //WRITE YOUR CODE HERE: 8 | 9 | int degreesCelsius; 10 | 11 | 12 | //DO NOT TOUCH BELOW LINES. 13 | degreesCelsius = 35; 14 | System.out.println(degreesCelsius); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ReplitSolutions/_3_001_String_VerifyContains.java: -------------------------------------------------------------------------------- 1 | //Write a program that will verify if the **sentence** contains **word**. 2 | // Print out the result as a boolean value. 3 | 4 | import java.util.Scanner; 5 | 6 | public class _3_001_String_VerifyContains { 7 | public static void main(String[] args) { 8 | Scanner scan = new Scanner(System.in); 9 | String word = scan.nextLine(); 10 | String sentence = scan.nextLine(); 11 | //WRITE YOUR CODE HERE 12 | System.out.println(sentence.contains(word)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ReplitSolutions/_3_004_String_PrintFirstCharacter.java: -------------------------------------------------------------------------------- 1 | //Write a program that will print out the first character of the word. 2 | // 3 | // Ex: 4 | // 5 | // ``` 6 | // Input: jump 7 | // ``` 8 | // ``` 9 | // Output: j 10 | // ``` 11 | 12 | 13 | import java.util.Scanner; 14 | 15 | public class _3_004_String_PrintFirstCharacter { 16 | public static void main(String[] args) { 17 | //DO NOT CHANGE 18 | Scanner scan = new Scanner(System.in); 19 | String word = scan.next(); 20 | //WRITE YOUR CODE HERE: 21 | 22 | System.out.println(word.charAt(0)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ReplitSolutions/_3_005_String_PrintLastCharacter.java: -------------------------------------------------------------------------------- 1 | //Write a program that will print out last letter of the word (string). 2 | // 3 | // Ex: 4 | // ``` 5 | // Input: java 6 | // ``` 7 | // ``` 8 | // Output: a 9 | // ``` 10 | 11 | import java.util.Scanner; 12 | 13 | public class _3_005_String_PrintLastCharacter { 14 | public static void main(String[] args) { 15 | //DO NOT CHANGE 16 | Scanner scan = new Scanner(System.in); 17 | String word = scan.next(); 18 | //WRITE YOUR CODE HERE 19 | System.out.println(word.charAt(word.length()-1)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ReplitSolutions/_3_006_String_PrintFirstAndLastLetters.java: -------------------------------------------------------------------------------- 1 | //Write a program that will print out first and last letters together. 2 | // 3 | // ``` 4 | // Input: adobe 5 | // ``` 6 | // 7 | // ``` 8 | // Output: ae 9 | // ``` 10 | 11 | import java.util.Scanner; 12 | 13 | public class _3_006_String_PrintFirstAndLastLetters { 14 | public static void main(String[] args) { 15 | //DO NOT CHANGE 16 | Scanner scan = new Scanner(System.in); 17 | String word = scan.next(); 18 | //WRITE YOUR CODE HERE 19 | 20 | 21 | System.out.println(Character.toString(word.charAt(0))+Character.toString(word.charAt(word.length()-1))); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ReplitSolutions/_4_013_Loops_PrintEvenFrom80To20.java: -------------------------------------------------------------------------------- 1 | //Write a for loop that prints all even integers from 80 through and including 20. 2 | // Separate each number with a space 3 | 4 | public class _4_013_Loops_PrintEvenFrom80To20 { 5 | public static void main(String[] args) { 6 | 7 | int start=80; 8 | int end=20; 9 | 10 | for(int i=start; i>=end ; i=i-2) 11 | { 12 | System.out.print(i); 13 | if(i!=end) 14 | { 15 | System.out.print(" "); 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ReplitSolutions/_6_024_Methods_MethodsWithReturn3Locks.java: -------------------------------------------------------------------------------- 1 | //**threeLocks** accepts 3 booleans and returns a boolean. 2 | // 3 | // It returns true only if both **_a and b are true_** or **_c is true_**. 4 | // 5 | // Hint: See truth table 6 | 7 | import java.util.Scanner; 8 | 9 | public class _6_024_Methods_MethodsWithReturn3Locks { 10 | public static boolean threeLocks(boolean a, boolean b, boolean c) 11 | { 12 | boolean result=(a && b) || c; 13 | return result; 14 | 15 | }//end threeLocks 16 | 17 | public static void main(String[] args) { 18 | Scanner in = new Scanner(System.in); 19 | System.out.println(threeLocks(in.nextBoolean(), in.nextBoolean(),in.nextBoolean())); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ReplitSolutions/_6_036_Methods_MethodsWithStringRemoveFirstChar.java: -------------------------------------------------------------------------------- 1 | //The method accepts a string and returns a string without the first character 2 | // 3 | // Example: 4 | // ``` 5 | // removeFirst("aaa") 6 | // 7 | // returns "aa" 8 | // 9 | // ``` 10 | 11 | import java.util.Scanner; 12 | 13 | public class _6_036_Methods_MethodsWithStringRemoveFirstChar { 14 | public static String removeFirst(String target) { 15 | 16 | return target.substring(1); 17 | } 18 | 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | System.out.println(removeFirst(in.next())); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ReplitSolutions/assignment9/Question03.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cybertek-EU7/JavaProgramming_EU7/e0e45ecf7eac1fed584c7a4b692a8a626683ba31/ReplitSolutions/assignment9/Question03.java -------------------------------------------------------------------------------- /ReplitSolutions/assignment9/Question04.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cybertek-EU7/JavaProgramming_EU7/e0e45ecf7eac1fed584c7a4b692a8a626683ba31/ReplitSolutions/assignment9/Question04.java -------------------------------------------------------------------------------- /ReplitSolutions/assignment9/Question05.java: -------------------------------------------------------------------------------- 1 | package assignment9; 2 | 3 | public class Question05 { 4 | 5 | public static void main(String[] args) { 6 | String word1 = "abc"; 7 | String word2 = "def"; 8 | 9 | if (word1.length() != 3 || word2.length() != 3) { 10 | System.out.println("cannot merge"); 11 | } else { 12 | for (int i = 0; i < word1.length(); i++) { 13 | char c = word1.charAt(i); 14 | char d = word2.charAt(i); 15 | System.out.print(c); 16 | System.out.print(d); 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /ReplitSolutions/assignment9/Question06.java: -------------------------------------------------------------------------------- 1 | package assignment9; 2 | 3 | public class Question06 { 4 | 5 | public static void main(String[] args) { 6 | String word = "abcde"; 7 | 8 | if (word.length() > 5) { 9 | System.out.println("too long"); 10 | } else if (word.length() < 5) { 11 | System.out.println("too short"); 12 | } else if (word.length()==5){ 13 | for (int i = 4; i >= 0; i--) { 14 | char c = word.charAt(i); 15 | System.out.print(c); 16 | 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /ReplitSolutions/assignment9/Question07.java: -------------------------------------------------------------------------------- 1 | package assignment9; 2 | 3 | public class Question07 { 4 | 5 | public static void main(String[] args) { 6 | String word = "java"; 7 | 8 | if (word.length() % 2 == 0) { 9 | String half = word.substring(0, word.length() / 2); 10 | System.out.println(half + half); 11 | } else { 12 | System.out.println("invalid"); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ReplitSolutions/assignment9/Question08.java: -------------------------------------------------------------------------------- 1 | package assignment9; 2 | 3 | public class Question08 { 4 | 5 | public static void main(String[] args) { 6 | String email="important project, Alejandro we refer to you this"; 7 | 8 | if (email.contains("Alejandro")) { 9 | System.out.println("read this mail"); 10 | }else { 11 | System.out.println("do not read"); 12 | } 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /ReplitSolutions/assignment9/Question09.java: -------------------------------------------------------------------------------- 1 | package assignment9; 2 | 3 | public class Question09 { 4 | 5 | public static void main(String[] args) { 6 | String email = "mike_tyson@gmail.com"; 7 | 8 | if (email.contains("_")) { 9 | int underscore = email.indexOf("_"); 10 | int place = email.indexOf("@"); 11 | String name = email.substring(0, underscore); 12 | String surname = email.substring(underscore + 1, place); 13 | String add = email.substring(place); 14 | System.out.println(surname + "_" + name + add); 15 | } else { 16 | System.out.println(email); 17 | } 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /ReplitSolutions/assignment9/Question12.java: -------------------------------------------------------------------------------- 1 | package assignment9; 2 | 3 | public class Question12 { 4 | 5 | public static void main(String[] args) { 6 | String str = "applex"; 7 | 8 | if (str.startsWith("x")||str.startsWith("X")) 9 | str = str.substring(1); 10 | if (str.endsWith("x")||str.endsWith("X")) 11 | str = str.substring(0, str.length() - 1); 12 | System.out.println(str); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /live_review_sections/week1/CarInfo.java: -------------------------------------------------------------------------------- 1 | package week1; 2 | 3 | public class CarInfo { 4 | 5 | public static void main(String[] args) { 6 | 7 | int year = 2021; 8 | String make = "Audi"; 9 | String model = "Q8"; 10 | String transmission = "Automatic"; 11 | String color = "white\\black"; 12 | int price = 100_000; 13 | 14 | System.out.println(year+" "+make+" "+model+" "+transmission+" " 15 | +" "+color+" "+price+ "Euro"); 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /live_review_sections/week1/PrintStatements.java: -------------------------------------------------------------------------------- 1 | package week1; 2 | 3 | public class PrintStatements { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Hello EU7, Welcome to Cybertek"); 8 | 9 | System.out.println("Hi"); 10 | 11 | System.out.println("------------------------------------"); 12 | 13 | System.out.print("Hello EU7, Welcome to Cybertek"); 14 | 15 | System.out.println("Hi"); // print Hi to console than go to next line 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /live_review_sections/week1/ScanerExample.java: -------------------------------------------------------------------------------- 1 | package week1; 2 | 3 | import java.util.Scanner; 4 | 5 | public class ScanerExample { 6 | public static void main(String[] args) { 7 | 8 | // output console 9 | System.out.println("Output"); 10 | 11 | //input from console: we use Scanner class and object we created that class 12 | 13 | // 1. create your scanner object 14 | Scanner input = new Scanner (System.in); 15 | 16 | // 2. prompt user 17 | 18 | System.out.println("Put your name: "); 19 | 20 | //3. get the input 21 | 22 | String name = input.next(); // nextInt(), nextDouble() 23 | 24 | //4. Use the value you got 25 | 26 | System.out.println("your name is: "+ name); 27 | 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /live_review_sections/week1/TellMeAboutYourself.java: -------------------------------------------------------------------------------- 1 | package week1; 2 | 3 | public class TellMeAboutYourself { 4 | 5 | public static void main(String[] args) { 6 | System.out.print("My name is Oscar\n "); 7 | System.out.println("\t I live in Turkiye"); 8 | System.out.println("I \"teach JAVA\""); 9 | System.out.println("My dream job is to become a SDET"); 10 | 11 | 12 | 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /live_review_sections/week1/_Shapes.java: -------------------------------------------------------------------------------- 1 | package week1; 2 | 3 | public class _Shapes { 4 | 5 | // escape squences 6 | // \t: paragraph space 7 | // \n: append new line 8 | // \" print " 9 | // \\ : prints \ 10 | 11 | public static void main(String[] args) { 12 | 13 | System.out.println("Make triangle\n---------------------------"); 14 | System.out.println("\tI want to start my triangle from here"); 15 | System.out.println("\t ^"); 16 | System.out.println("\t / \\\\"); 17 | 18 | } 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /live_review_sections/week10/AmazonInc.java: -------------------------------------------------------------------------------- 1 | package week10; 2 | 3 | public class AmazonInc { 4 | 5 | public static void main(String[] args) { 6 | 7 | Tester tester = new Tester("Polad", "SDET", 'M', 35, 100000); 8 | 9 | tester.setJobTitle("Quality Engineer"); 10 | tester.setAge(25); 11 | tester.findBugs(); 12 | 13 | Developer developer = new Developer("Ibrahim", "Front End Developer", 'M', 35, 150000); 14 | 15 | developer.fixBugs(); 16 | developer.setSalary(0); 17 | System.out.println(developer.getSalary()); 18 | 19 | 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /live_review_sections/week10/Developer.java: -------------------------------------------------------------------------------- 1 | package week10; 2 | 3 | public class Developer extends Employee { 4 | 5 | public Developer(String name, String jobTitle, char gender, int age, double salary) { 6 | super(name, jobTitle, gender, age, salary); 7 | 8 | } 9 | 10 | @Override 11 | public void work() { 12 | System.out.println(getName()+ " is coding"); 13 | } 14 | 15 | public void fixBugs() { 16 | System.out.println(getName()+" is fixing the bug like men"); 17 | } 18 | 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /live_review_sections/week10/SupportPersonel.java: -------------------------------------------------------------------------------- 1 | package week10; 2 | 3 | public class SupportPersonel extends Employee{ 4 | 5 | public SupportPersonel(String name, String jobTitle, char gender, int age, double salary) { 6 | 7 | super(name, jobTitle, gender, age, salary); 8 | 9 | } 10 | 11 | @Override 12 | public void work() { 13 | System.out.println(getName()+ " is supporting everbody with their HARD work"); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /live_review_sections/week10/Tester.java: -------------------------------------------------------------------------------- 1 | package week10; 2 | 3 | public class Tester extends Employee { 4 | 5 | public Tester(String name, String jobTitle, char gender, int age, double salary) { 6 | super(name, jobTitle, gender, age, salary); 7 | } 8 | 9 | @Override 10 | public void work() { 11 | System.out.println(getName() + " is testing"); 12 | } 13 | 14 | public void findBugs() { 15 | System.out.println(getName()+" found a bug"); 16 | } 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /live_review_sections/week11/FinalKeyword.java: -------------------------------------------------------------------------------- 1 | package week11; 2 | 3 | public class FinalKeyword { 4 | 5 | final String name; 6 | final int age; 7 | final static String color ; // can be initialized at the same line or inside Static block 8 | 9 | 10 | public FinalKeyword(String name) { 11 | this.name = name; 12 | // this.color = color; Not possible 13 | } 14 | 15 | { 16 | this.age = 28; 17 | } 18 | 19 | static { 20 | color = "black"; 21 | } 22 | 23 | public static void main(String[] args) { 24 | 25 | final int x; // declare 26 | x= 10; 27 | System.out.println(x); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /live_review_sections/week11/car_examples/BMW.java: -------------------------------------------------------------------------------- 1 | package week11.car_examples; 2 | 3 | public class BMW extends Car { 4 | 5 | public BMW(String model, String make, String color, int year) { 6 | super(model,color, year); 7 | super.make = make; 8 | } 9 | 10 | @Override 11 | public void start() { 12 | 13 | System.out.println("Push the start button"); 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /live_review_sections/week11/car_examples/Car.java: -------------------------------------------------------------------------------- 1 | package week11.car_examples; 2 | 3 | public abstract class Car extends Object{ 4 | 5 | public String model,make,color; 6 | public int year; 7 | 8 | 9 | 10 | public Car(String model, String color, int year) { 11 | this.model = model; 12 | this.color = color; 13 | this.year = year; 14 | } 15 | 16 | 17 | 18 | public abstract void start(); 19 | 20 | 21 | 22 | 23 | public String toString() { 24 | return "Car [model=" + model + ", make=" + make + ", color=" + color + ", year=" + year + "]"; 25 | } 26 | 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /live_review_sections/week11/car_examples/ParkingLot.java: -------------------------------------------------------------------------------- 1 | package week11.car_examples; 2 | 3 | public class ParkingLot { 4 | 5 | public static void main(String[] args) { 6 | 7 | // Car car = new Car(); can not instantiate from abstract class 8 | 9 | Toyota camry = new Toyota("Camry", "White", 2019); 10 | 11 | camry.start(); 12 | System.out.println(camry.toString()); 13 | 14 | BMW M5 = new BMW("M5", "BMW", "Black", 2021); 15 | 16 | M5.start(); 17 | System.out.println(M5); 18 | 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /live_review_sections/week11/car_examples/Tesla.java: -------------------------------------------------------------------------------- 1 | package week11.car_examples; 2 | 3 | public final class Tesla extends Car { 4 | 5 | public Tesla(String model, String color, int year) { 6 | super(model,color, year); 7 | super.make = "Tesla"; 8 | } 9 | 10 | 11 | public void start() { 12 | 13 | System.out.println("Say start"); 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /live_review_sections/week11/car_examples/Toyota.java: -------------------------------------------------------------------------------- 1 | package week11.car_examples; 2 | 3 | public class Toyota extends Car { 4 | 5 | public Toyota(String model, String color, int year) { 6 | super(model, color, year); 7 | super.make = "Toyota"; 8 | } 9 | 10 | @Override 11 | public void start() { 12 | 13 | System.out.println("Twist the key to ignite"); 14 | 15 | } 16 | 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /live_review_sections/week11/exercise_example/AtTheGym.java: -------------------------------------------------------------------------------- 1 | package week11.exercise_example; 2 | 3 | public class AtTheGym { 4 | 5 | public static void main(String[] args) { 6 | 7 | FreeWeight freeWeight = new FreeWeight(); 8 | 9 | freeWeight.start(); 10 | System.out.println("I lifted weight for 30 minutes : " 11 | + freeWeight.getCaloriesCount(30) + "Calories"); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /live_review_sections/week11/exercise_example/Exercise.java: -------------------------------------------------------------------------------- 1 | package week11.exercise_example; 2 | 3 | public abstract class Exercise { 4 | 5 | public void start() { 6 | System.out.println("Warming up and starting the exercise"); 7 | } 8 | 9 | public abstract void perform(); 10 | 11 | public abstract int getCaloriesCount(int minutes); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /live_review_sections/week11/exercise_example/FreeWeight.java: -------------------------------------------------------------------------------- 1 | package week11.exercise_example; 2 | 3 | public class FreeWeight extends Lifting{ 4 | 5 | @Override 6 | public void endLift() { 7 | 8 | System.out.println("Carefully placing the weights"); 9 | 10 | } 11 | 12 | @Override 13 | public void perform() { 14 | 15 | System.out.println("Lifting Free Weight dumbbells"); 16 | 17 | } 18 | 19 | @Override 20 | public int getCaloriesCount(int minutes) { 21 | 22 | 23 | return minutes*6; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /live_review_sections/week11/exercise_example/Lifting.java: -------------------------------------------------------------------------------- 1 | package week11.exercise_example; 2 | 3 | public abstract class Lifting extends Exercise{ 4 | 5 | public abstract void endLift(); 6 | } 7 | -------------------------------------------------------------------------------- /live_review_sections/week11/exercise_example/Running.java: -------------------------------------------------------------------------------- 1 | package week11.exercise_example; 2 | 3 | public class Running extends Exercise{ 4 | 5 | @Override 6 | public void perform() { 7 | // TODO Auto-generated method stub 8 | 9 | } 10 | 11 | @Override 12 | public int getCaloriesCount(int minutes) { 13 | // TODO Auto-generated method stub 14 | return 0; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /live_review_sections/week11/exercise_example/Swimming.java: -------------------------------------------------------------------------------- 1 | package week11.exercise_example; 2 | 3 | public class Swimming extends Exercise{ 4 | 5 | @Override 6 | public void perform() { 7 | // TODO Auto-generated method stub 8 | 9 | } 10 | 11 | @Override 12 | public int getCaloriesCount(int minutes) { 13 | // TODO Auto-generated method stub 14 | return 0; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /live_review_sections/week12/interface_demo/WebDriver.java: -------------------------------------------------------------------------------- 1 | package week12.interface_demo; 2 | 3 | public interface WebDriver { 4 | // these are all abstract method with no Return or vith return 5 | void get (String url); // public abstract 6 | void findElement(String locator); 7 | void quit(); 8 | String getTitle(); 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /live_review_sections/week12/polymorphism_demo/Father.java: -------------------------------------------------------------------------------- 1 | package week12.polymorphism_demo; 2 | 3 | public class Father { 4 | 5 | public void raiseKid() { 6 | System.out.println("Father is raising his kids"); 7 | } 8 | 9 | public void feedKid() { 10 | System.out.println("Father is feeding his Kid"); 11 | } 12 | 13 | public void playWithKid() { 14 | System.out.println("Father is playing with his Kid"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /live_review_sections/week12/polymorphism_demo/Superman.java: -------------------------------------------------------------------------------- 1 | package week12.polymorphism_demo; 2 | 3 | public class Superman extends Father implements Worker{ 4 | 5 | @Override 6 | public void work(String job) { 7 | System.out.println("Superman is working as "+ job); 8 | 9 | } 10 | 11 | @Override 12 | public double getPaid() { 13 | System.out.println("getting paid"); 14 | return 8000; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /live_review_sections/week12/polymorphism_demo/Worker.java: -------------------------------------------------------------------------------- 1 | package week12.polymorphism_demo; 2 | 3 | public interface Worker { 4 | 5 | void work(String job); 6 | 7 | double getPaid(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /live_review_sections/week13/FinallyBlock.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | import java.util.InputMismatchException; 4 | import java.util.Scanner; 5 | 6 | public class FinallyBlock { 7 | 8 | public static void main(String[] args) { 9 | 10 | Scanner scan = new Scanner(System.in); 11 | 12 | try { 13 | System.out.println("Enter a number"); 14 | int num = scan.nextInt(); 15 | System.out.println("You entered : "+ num); 16 | }catch(InputMismatchException e) { 17 | System.out.println("Hey Buddy please read the message carefully"); 18 | }finally { 19 | scan.close(); // close and clean up the scanner 20 | System.out.println("Finally block runs no matter what"); 21 | } 22 | 23 | 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /live_review_sections/week13/StringIndexProblem.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | public class StringIndexProblem { 4 | 5 | public static void main(String[] args) { 6 | 7 | String word = "java"; 8 | 9 | try { 10 | System.out.println(word.charAt(10)); 11 | }catch(Exception e) { 12 | System.out.println(e.getMessage()); 13 | System.out.println("Type of eception: " + e.getClass().getSimpleName()); 14 | 15 | } 16 | 17 | System.out.println(word.toUpperCase()); 18 | 19 | 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /live_review_sections/week13/customExceptions/BreakTimeException.java: -------------------------------------------------------------------------------- 1 | package week13.customExceptions; 2 | 3 | public class BreakTimeException extends RuntimeException{ 4 | // I am inheriting all the methods of RunTimeException 5 | 6 | public BreakTimeException() { 7 | 8 | } 9 | 10 | public BreakTimeException(String message) { 11 | super(message); // call super class constructor 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /live_review_sections/week13/customExceptions/CustomExceptionTest.java: -------------------------------------------------------------------------------- 1 | package week13.customExceptions; 2 | 3 | public class CustomExceptionTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | int minutes = 50; 8 | 9 | System.out.println("Class is going on for "+ minutes+" minutes"); 10 | 11 | if(minutes > 45) { 12 | throw new BreakTimeException("It is break time Hocam"); 13 | } 14 | 15 | System.out.println("Let's continue the class another "+(45-minutes) 16 | +" minutes"); 17 | 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /live_review_sections/week14/ListIsEqualToSetExample.java: -------------------------------------------------------------------------------- 1 | package week14; 2 | 3 | import java.util.*; 4 | 5 | public class ListIsEqualToSetExample { 6 | public static void main(String[] args) { 7 | 8 | List list = new ArrayList(Arrays.asList(1,2,3,4,5)); 9 | 10 | List listTwo = new ArrayList(Arrays.asList(1,2,3,4,5)); 11 | 12 | Set set = new TreeSet<>(Arrays.asList(1,2,3,4,5)); 13 | 14 | System.out.println(list.equals(set)); // false 15 | System.out.println(list.equals(listTwo)); // true 16 | 17 | // how can I verify if set and list is same or includes 18 | 19 | System.out.println(list.containsAll(set)); // true 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /live_review_sections/week2/AddNumbersfromReplit.java: -------------------------------------------------------------------------------- 1 | package week2; 2 | 3 | import java.util.Scanner; 4 | 5 | public class AddNumbersfromReplit { 6 | 7 | public static void main(String[] args) { 8 | //WRITE YOUR CODE HERE: 9 | int num1, num2, num3; // declared the variable 10 | 11 | double num4, sum; 12 | Scanner scan = new Scanner (System.in); 13 | 14 | System.out.println("Enter 4 numbers:"); 15 | num1 = scan.nextInt(); 16 | num2 = scan.nextInt(); 17 | num3 = scan.nextInt(); 18 | num4 = scan.nextDouble(); 19 | 20 | // not necessary but you can close that object 21 | scan.close(); 22 | 23 | 24 | sum = num1 + num2 + num3 + num4 ; 25 | 26 | System.out.println("Sum of numbers: "+sum); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /live_review_sections/week2/EvenorOdd.java: -------------------------------------------------------------------------------- 1 | package week2; 2 | 3 | public class EvenorOdd { 4 | 5 | public static void main(String[] args) { 6 | 7 | int number = 100;// check if this is even or not 8 | 9 | if (number%2==0) { 10 | System.out.println("Even"); 11 | }else { 12 | System.out.println("Odd"); 13 | } 14 | 15 | 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /live_review_sections/week2/RelationalOperators.java: -------------------------------------------------------------------------------- 1 | package week2; 2 | 3 | public class RelationalOperators { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println(100 > 1000); // false 8 | 9 | System.out.println('A' == 65); // true 10 | 11 | System.out.println(15 >= 15); 12 | 13 | System.out.println("---------Question from Discord-------------"); 14 | 15 | int b = 2; 16 | boolean res = ++b == 2 || --b == 2 && --b == 2; // 17 | System.out.println(res); 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /live_review_sections/week2/SwitchInTestersLife.java: -------------------------------------------------------------------------------- 1 | package week2; 2 | 3 | import java.util.Scanner; 4 | 5 | public class SwitchInTestersLife { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner input = new Scanner (System.in); 10 | 11 | System.out.println("Browser Type to Automate"); 12 | 13 | String browser = input.next(); 14 | 15 | 16 | switch (browser) { 17 | 18 | case("chrome"): 19 | System.out.println("Doing chrome automation"); 20 | break; 21 | 22 | case("firefox"): 23 | System.out.println("Doing firefox automation"); 24 | break; 25 | 26 | default: 27 | System.out.println("wrong entry"); 28 | } 29 | 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /live_review_sections/week3/BasicLoopExamples.java: -------------------------------------------------------------------------------- 1 | package week3; 2 | 3 | public class BasicLoopExamples { 4 | 5 | public static void main(String[] args) { 6 | 7 | for(int i=0 ; i<10 ; i+=1 ) { 8 | System.out.print("Hello "); 9 | } 10 | 11 | // System.out.println(i); just local to the for loop 12 | System.out.println(""); 13 | System.out.println("--------------------------------------"); 14 | 15 | for(int i=1; i<=10 ; i++) { 16 | 17 | System.out.println("2 X "+i+" = "+(2*i)); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /live_review_sections/week3/CustomMethod2.java: -------------------------------------------------------------------------------- 1 | package week3; 2 | 3 | public class CustomMethod2 { 4 | 5 | public static void main(String[] args) { 6 | 7 | int person1 = 10; 8 | eligibleOrNot(person1); 9 | 10 | eligibleOrNot(20); 11 | 12 | eligibleOrNot(24); 13 | 14 | } 15 | 16 | public static void eligibleOrNot(int age) { 17 | 18 | int person = age; 19 | 20 | if (person>=21) { 21 | System.out.println("Eligible to buy"); 22 | }else { 23 | System.out.println("NOT Eligible to buy"); 24 | } 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /live_review_sections/week3/CustomMethod3.java: -------------------------------------------------------------------------------- 1 | package week3; 2 | 3 | public class CustomMethod3 { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println(getAgeInDays(10) + " Days old. "); 8 | 9 | System.out.println(getAgeInDaysWithMSG(10)); 10 | } 11 | 12 | 13 | public static int getAgeInDays(int years) { 14 | 15 | // int days = years * 365; 16 | 17 | return years * 365; 18 | } 19 | 20 | 21 | public static String getAgeInDaysWithMSG(int years) { 22 | 23 | return (years * 365) + " Days old."; 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /live_review_sections/week3/CustomMethods1.java: -------------------------------------------------------------------------------- 1 | package week3; 2 | 3 | public class CustomMethods1 { 4 | 5 | public static void main(String[] args) { 6 | 7 | int person1 = 10; 8 | if (person1>=21) { 9 | System.out.println("Eligible to buy"); 10 | }else { 11 | System.out.println("NOT Eligible to buy"); 12 | } 13 | 14 | int person2 = 20; 15 | if (person2>=21) { 16 | System.out.println("Eligible to buy"); 17 | }else { 18 | System.out.println("NOT Eligible to buy"); 19 | } 20 | 21 | int person3 = 24; 22 | if (person3>=21) { 23 | System.out.println("Eligible to buy"); 24 | }else { 25 | System.out.println("NOT Eligible to buy"); 26 | } 27 | 28 | 29 | 30 | 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /live_review_sections/week3/PrintAllLetters.java: -------------------------------------------------------------------------------- 1 | package week3; 2 | 3 | public class PrintAllLetters { 4 | 5 | public static void main(String[] args) { 6 | 7 | // Print all the letters from A to Z 8 | 9 | for (char c = 'A'; c <= 'Z'; c++) { 10 | System.out.print(c + " "); 11 | } 12 | 13 | System.out.println(""); 14 | for (int i=65; i<=90 ; i++) { 15 | System.out.print((char)i+" "); 16 | } 17 | 18 | System.out.println(""); 19 | 20 | for (int i = 'z'; i>='a'; i--) { // this is an example of implicit casting-compiler 21 | System.out.print((char)i+" "); // this is an example of explicit casting- we do it 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /live_review_sections/week3/TernaryExample.java: -------------------------------------------------------------------------------- 1 | package week3; 2 | 3 | public class TernaryExample { 4 | 5 | public static void main(String[] args) { 6 | 7 | int num1 = 100; 8 | int num2 = 10000; 9 | int biggerNumber; 10 | 11 | // if(num1>num2) { 12 | // biggerNumber=num1; 13 | // 14 | // }else { 15 | // biggerNumber=num2; 16 | // } 17 | 18 | biggerNumber = (num1>num2)? num1 : num2; 19 | 20 | System.out.println(biggerNumber); 21 | 22 | 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /live_review_sections/week3/Week3Notes.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cybertek-EU7/JavaProgramming_EU7/e0e45ecf7eac1fed584c7a4b692a8a626683ba31/live_review_sections/week3/Week3Notes.txt -------------------------------------------------------------------------------- /live_review_sections/week4/AmazonTest_2.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | public class AmazonTest_2 { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("--Starting Amazon Search Functional Test--"); 8 | AmazonTest.openBrowser(); 9 | AmazonTest.navigateToAmazonPage(); 10 | AmazonTest.searchForAnItem("Selenium"); 11 | AmazonTest.verifyResultsAreDisplayed(); 12 | System.out.println("Amazon Search Functional Test compeleted-PASS-"); 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /live_review_sections/week4/BankAccount.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | public class BankAccount { 4 | 5 | String accountHolderName; 6 | int pin; 7 | double balance; 8 | long accountNumber; 9 | 10 | public double getBalance(int inputPin) { 11 | if(pin==inputPin) { 12 | return balance; 13 | } 14 | return -1; 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /live_review_sections/week4/CalculatorOverLoading.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | public class CalculatorOverLoading { 4 | 5 | public static void main(String[] args) { 6 | 7 | } 8 | 9 | public static double add(double num1, double num2) { 10 | double result = num1 + num2; 11 | return result; 12 | } 13 | 14 | public static double add(double num1, double num2,double num3) { // number of parameters 15 | double result = num1 + num2 + num3; 16 | return result; 17 | } 18 | 19 | public static int add(int num1, int num2) { // datatype of parameters 20 | int result = num1 + num2; 21 | return result; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /live_review_sections/week4/GarbageExample.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | public class GarbageExample { 4 | 5 | public static void main(String[] args) { 6 | 7 | String str = "JAVA"; 8 | 9 | str = "python"; // "JAVA" object is unreferenced and eligible for garbage collection 10 | 11 | System.out.println(str); 12 | 13 | 14 | str = null; // "python" is unreferenced and eligible for garbage collection 15 | System.out.println(str); 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /live_review_sections/week4/ImportExample.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | import week3.CustomMethod3; 4 | 5 | public class ImportExample { 6 | 7 | public static void main(String[] args) { 8 | 9 | System.out.println(CustomMethod3.getAgeInDays(35)); 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /live_review_sections/week4/LocalVsInstance.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | public class LocalVsInstance { 4 | 5 | int a = 20; // instance variable 6 | 7 | 8 | public void showDifference() { 9 | int a =5; // local variable 10 | System.out.println(a); 11 | } 12 | 13 | 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /live_review_sections/week4/LocalVsInstanceTest.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | public class LocalVsInstanceTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | LocalVsInstance obj = new LocalVsInstance(); 8 | 9 | System.out.println(" -----local variable-------"); 10 | obj.showDifference(); 11 | 12 | System.out.println("------instance variable-------"); 13 | obj.a=10; 14 | System.out.println(obj.a); 15 | 16 | 17 | 18 | for (int i = 0; i<10; i++) { // i is local to for loop 19 | System.out.println(i+" "); 20 | } 21 | // System.out.println(i); local variable can NOT print here 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /live_review_sections/week4/SalaryTest.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | public class SalaryTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | Salary shevki = new Salary(); 9 | shevki.setInfo(70, 45, 0.19); 10 | 11 | System.out.println(shevki.salaryAfterTax()); 12 | 13 | Salary hande = new Salary(); 14 | hande.setInfo(100, 35, 0.15); 15 | System.out.println(hande.salaryAfterTax()); 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /live_review_sections/week4/ScrumTeam.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | public class ScrumTeam { 4 | 5 | String companyName; 6 | int developers; 7 | int testers; 8 | double developerSalary; 9 | double testerSalary; 10 | double companyRevenue; 11 | 12 | public double costOfTheTeam() { 13 | return developers*developerSalary+testers*testerSalary; 14 | } 15 | 16 | 17 | 18 | public double returnOfInvestment() { 19 | return companyRevenue/costOfTheTeam(); 20 | } 21 | 22 | public void createCompany(String name, int devNums, int tesNums) { // setter method 23 | companyName = name; 24 | developers = devNums; 25 | testers = tesNums; 26 | } 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /live_review_sections/week4/TestCase.java: -------------------------------------------------------------------------------- 1 | package week4; 2 | 3 | public class TestCase { 4 | 5 | // P.I.Q.: How Do You write a Test Case? 6 | 7 | String testCaseID; 8 | String testCaseDescription; 9 | int numberOfTestSteps; 10 | boolean isPassed; 11 | 12 | // HW : create more attributes and some actions 13 | // create a class with main method and create objects of TestCases 14 | } 15 | -------------------------------------------------------------------------------- /live_review_sections/week5/S04_IndexOfExample.java: -------------------------------------------------------------------------------- 1 | package week5; 2 | 3 | public class S04_IndexOfExample { 4 | 5 | public static void main(String[] args) { 6 | 7 | String message = "Java is Awesome! Akgkf !! AA kgfkdls!"; 8 | 9 | // this method takes a String and returns it's index 10 | 11 | int begining = message.indexOf("Awe"); 12 | int ending = message.indexOf("me!")+2; 13 | 14 | String word = message.substring(begining,ending); 15 | 16 | System.out.println(word); 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /live_review_sections/week5/S09_FrequencyOfWord.java: -------------------------------------------------------------------------------- 1 | package week5; 2 | 3 | public class S09_FrequencyOfWord { 4 | 5 | public static void main(String[] args) { 6 | String sentence = "I am an experienced tester. As a tester I can automate browsers." 7 | + " I can test API and DB test"; 8 | String word = "test"; 9 | 10 | System.out.println(freqOfWord(sentence, word)); 11 | } 12 | 13 | 14 | public static int freqOfWord(String str, String word) { 15 | int count = 0; 16 | 17 | for (int i = 0; i <= str.length()-word.length();i++) { 18 | String each = str.substring(i, i+word.length()); 19 | if(each.equalsIgnoreCase(word)) { 20 | count++; 21 | } 22 | 23 | } 24 | 25 | return count; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /live_review_sections/week6/A07_SentenceSplit.java: -------------------------------------------------------------------------------- 1 | package week6; 2 | 3 | public class A07_SentenceSplit { 4 | public static void main(String[] args) { 5 | 6 | String amazonResult = "1-48 x of x over x 6,000 x results x for x java"; 7 | 8 | 9 | String[] resultArray = amazonResult.split("x"); 10 | System.out.println(resultArray.length); 11 | System.out.println("How many results are there in my search: "+ resultArray[3] ); 12 | System.out.println("First element : "+ resultArray[0]); 13 | System.out.println("Second Element : "+ resultArray[1]); 14 | System.out.println("Number of 'x' in my statement : " + (resultArray.length-1) ); 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /live_review_sections/week6/QuizQ4.java: -------------------------------------------------------------------------------- 1 | package week6; 2 | 3 | public class QuizQ4 { 4 | 5 | public static void main(String[] args) { 6 | int wd = 0; //-1, 0, 2, 4, 3 7 | String [] days = {"sun","mon","wed","sat"}; 8 | 9 | for(int i=0; i 49 - > 50 - > 49 - > 50 11 | 12 | //result : 49 + 49 + 50 + 49 = 197 13 | 14 | System.out.println("a = " + a); 15 | System.out.println("result = " + result); 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day05_unary_assignment_relational_operators/Task20_IncrementDecrement.java: -------------------------------------------------------------------------------- 1 | package day05_unary_assignment_relational_operators; 2 | 3 | public class Task20_IncrementDecrement { 4 | 5 | public static void main(String[] args) { 6 | 7 | int a = 1; 8 | int result = -a-- + a++ / -a-- * --a; 9 | 10 | //a in memory : 1 - > 0 - > 1 - > 0 - > -1 11 | 12 | // result : -1 + 0 / -1 * -1 = > -1 + 0 * -1 = > -1 + 0 = > -1 13 | 14 | System.out.println("a = " + a); 15 | System.out.println("result = " + result); 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day05_unary_assignment_relational_operators/Task21_IncrementDecrement.java: -------------------------------------------------------------------------------- 1 | package day05_unary_assignment_relational_operators; 2 | 3 | public class Task21_IncrementDecrement { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | int x = 4; 9 | int y = x * 4 - x++; 10 | 11 | System.out.println("x = " + x); 12 | System.out.println("y = " + y); 13 | 14 | //x in memory : 4 - > 5 15 | //y : 4 * 4 - 4 = > 12 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day05_unary_assignment_relational_operators/Task22_RelationalOperator.java: -------------------------------------------------------------------------------- 1 | package day05_unary_assignment_relational_operators; 2 | 3 | public class Task22_RelationalOperator { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | int i1,i2; 9 | i1=100; 10 | i2=20; 11 | boolean b1=i1>i2; 12 | 13 | System.out.println("First Number is greater than second number - " + b1); 14 | 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day05_unary_assignment_relational_operators/TypeCasting.java: -------------------------------------------------------------------------------- 1 | package day05_unary_assignment_relational_operators; 2 | 3 | public class TypeCasting { 4 | 5 | public static void main(String[] args) { 6 | 7 | byte b; 8 | int i=81; 9 | double d=323.142; 10 | float f=72.38f; 11 | char c='A'; 12 | 13 | c=(char)i; 14 | System.out.println("i = " + i + " c = " + c); 15 | 16 | i=(int)d; 17 | System.out.println("d = " + d + " i = " + i); 18 | 19 | i=(int)f; 20 | System.out.println("f = " + f + " i = " + i); 21 | 22 | b=(byte)d; 23 | System.out.println("d = " + d + " b = " + b); 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/day06_logical_operators/Task23_Operators.java: -------------------------------------------------------------------------------- 1 | package day06_logical_operators; 2 | 3 | public class Task23_Operators { 4 | 5 | public static void main(String[] args) { 6 | 7 | double d1 = 20; 8 | double d2 = 80; 9 | 10 | double res = (d1+d2)*25; 11 | 12 | double remainder = res%40; 13 | 14 | System.out.println("Ramaining total is equal to 20 or less? - " + (remainder<=20)); 15 | 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day07_control_flow_statements/IfStatements.java: -------------------------------------------------------------------------------- 1 | package day07_control_flow_statements; 2 | 3 | public class IfStatements { 4 | 5 | public static void main(String[] args) { 6 | 7 | int score = 60; 8 | 9 | if(score>=70) { 10 | 11 | System.out.println("Excellent"); 12 | System.out.println("You passed with grade A"); 13 | 14 | } 15 | 16 | System.out.println("***********************"); 17 | 18 | int sales,bonus; 19 | double commisionRate,salary; 20 | 21 | sales=5000; 22 | salary=10000; 23 | 24 | if(sales>5000) { 25 | bonus=500; 26 | commisionRate=1.12; 27 | 28 | salary=salary*commisionRate+bonus; 29 | } 30 | 31 | System.out.println("Salary = " + salary); 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/day07_control_flow_statements/Task24_EligibleToVote.java: -------------------------------------------------------------------------------- 1 | package day07_control_flow_statements; 2 | 3 | public class Task24_EligibleToVote { 4 | 5 | public static void main(String[] args) { 6 | 7 | int age = 10; 8 | 9 | if(age>=18) { 10 | 11 | System.out.println("Eligible to vote"); 12 | } 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day07_control_flow_statements/Task25_GreatestNumber.java: -------------------------------------------------------------------------------- 1 | package day07_control_flow_statements; 2 | 3 | public class Task25_GreatestNumber { 4 | 5 | public static void main(String[] args) { 6 | 7 | int num1=40; 8 | int num2=8; 9 | int num3=100; 10 | 11 | 12 | if(num1>num2 && num1>num3) { 13 | System.out.println("Num1 is the greatest"); 14 | } 15 | 16 | if(num2>num1 && num2>num3) { 17 | System.out.println("Num2 is the greatest"); 18 | } 19 | 20 | if(num3>num1 && num3>num2) { 21 | System.out.println("Num3 is the greatest"); 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day07_control_flow_statements/Task26_EqualNumbers.java: -------------------------------------------------------------------------------- 1 | package day07_control_flow_statements; 2 | 3 | public class Task26_EqualNumbers { 4 | 5 | public static void main(String[] args) { 6 | 7 | int num1=10; 8 | int num2=10; 9 | 10 | if(num1==num2) { 11 | 12 | System.out.println("Numbers are equal"); 13 | 14 | } 15 | 16 | if(num1!=num2) { 17 | 18 | System.out.println("Numbers are not equal"); 19 | 20 | } 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day07_control_flow_statements/Task27_GreetingHours.java: -------------------------------------------------------------------------------- 1 | package day07_control_flow_statements; 2 | 3 | public class Task27_GreetingHours { 4 | 5 | public static void main(String[] args) { 6 | 7 | int hour = 14; 8 | 9 | if(hour<12) { 10 | System.out.println("Good Morning"); 11 | } 12 | 13 | if(hour>=12 && hour<15) { 14 | System.out.println("Good Afternoon"); 15 | } 16 | 17 | if(hour>=15) { 18 | System.out.println("Good Evening"); 19 | } 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day07_control_flow_statements/Task28_RevenueCalculator.java: -------------------------------------------------------------------------------- 1 | package day07_control_flow_statements; 2 | 3 | public class Task28_RevenueCalculator { 4 | 5 | public static void main(String[] args) { 6 | 7 | double price = 19.99; 8 | int quantity = 2000; 9 | 10 | double revenue; 11 | double discount=0; 12 | 13 | revenue=price*quantity; 14 | 15 | if(revenue>5000) { 16 | 17 | discount = revenue*0.1; 18 | revenue=revenue-discount; 19 | } 20 | 21 | System.out.println("discount = " + discount); 22 | System.out.println("revenue = " + revenue); 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day08_control_flow_statements_2/NestedIfStatement.java: -------------------------------------------------------------------------------- 1 | package day08_control_flow_statements_2; 2 | 3 | public class NestedIfStatement { //tollCalculator 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | boolean isRushHour=false; 9 | int carType=2; 10 | double price=0.0; 11 | 12 | if(carType==1) { 13 | if(isRushHour) { 14 | price=30.0; 15 | }else { 16 | price=5.0; 17 | } 18 | }else if(carType==2) { 19 | if(isRushHour) { 20 | price=55.30; 21 | }else { 22 | price=15.99; 23 | } 24 | 25 | } 26 | 27 | System.out.println("Toll Cost: " + price); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/day08_control_flow_statements_2/Task29_BiggerNumber.java: -------------------------------------------------------------------------------- 1 | package day08_control_flow_statements_2; 2 | 3 | public class Task29_BiggerNumber { 4 | 5 | public static void main(String[] args) { 6 | 7 | int num1=500; 8 | int num2=200; 9 | 10 | if(num1>num2) { 11 | 12 | System.out.println("Num1:" + num1 + " is bigger than " + "Num2:" + num2); 13 | 14 | }else { 15 | 16 | System.out.println("Num2:" + num2 + " is bigger than " + "Num1:" + num1); 17 | 18 | 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day08_control_flow_statements_2/Task30_EvenOddNumber.java: -------------------------------------------------------------------------------- 1 | package day08_control_flow_statements_2; 2 | 3 | public class Task30_EvenOddNumber { 4 | 5 | public static void main(String[] args) { 6 | 7 | int number=6; 8 | 9 | if(number%2==0) { 10 | System.out.println("Number:" + number + " is even number"); 11 | }else { 12 | System.out.println("Number:" + number + " is odd number"); 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/day08_control_flow_statements_2/Task31_TriangleAngles.java: -------------------------------------------------------------------------------- 1 | package day08_control_flow_statements_2; 2 | 3 | public class Task31_TriangleAngles { 4 | 5 | public static void main(String[] args) { 6 | 7 | int a=60; 8 | int b=60; 9 | int c=70; 10 | 11 | if((a+b+c)==180) { 12 | System.out.println("This is a valid triangle"); 13 | }else { 14 | System.out.println("This is not a valid triangle"); 15 | } 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day08_control_flow_statements_2/Task32_LargestNumber.java: -------------------------------------------------------------------------------- 1 | package day08_control_flow_statements_2; 2 | 3 | public class Task32_LargestNumber { 4 | 5 | public static void main(String[] args) { 6 | 7 | int num1=10000; 8 | int num2=2000; 9 | int num3=300; 10 | 11 | if((num1>num2)&&(num1>num3)) { 12 | System.out.println("Num1 is greatest one"); 13 | }else if((num2>num1)&&(num2>num3)) { 14 | System.out.println("Num2 is greatest one"); 15 | }else if((num3>num1)&&(num3>num2)) { 16 | System.out.println("Num3 is greatest one"); 17 | }else { 18 | System.out.println("Numbers are equal"); 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day08_control_flow_statements_2/Task33_Grading.java: -------------------------------------------------------------------------------- 1 | package day08_control_flow_statements_2; 2 | 3 | public class Task33_Grading { 4 | 5 | public static void main(String[] args) { 6 | 7 | int mark=90; 8 | 9 | if(mark<60) { 10 | System.out.println("Fail"); 11 | }else if(mark>=60 && mark<90) { 12 | System.out.println("Pass"); 13 | }else if(mark>90) { 14 | System.out.println("Passed with distinction"); 15 | }else { 16 | System.out.println("Invalid Score"); 17 | } 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day08_control_flow_statements_2/Task35_FindGreatestNested.java: -------------------------------------------------------------------------------- 1 | package day08_control_flow_statements_2; 2 | 3 | public class Task35_FindGreatestNested { 4 | 5 | public static void main(String[] args) { 6 | 7 | int n1=1000; 8 | int n2=2000; 9 | int n3=3000; 10 | 11 | //find the greatest by using nested if 12 | 13 | if(n1>n2 && n1>n3) { 14 | System.out.println("n1 is biggest"); 15 | }else { 16 | if(n2>n3) { 17 | System.out.println("n2 is biggest"); 18 | }else { 19 | System.out.println("n3 is biggest"); //n3>n2 20 | } 21 | } 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day08_control_flow_statements_2/Task36_Calculator.java: -------------------------------------------------------------------------------- 1 | package day08_control_flow_statements_2; 2 | 3 | public class Task36_Calculator { 4 | 5 | public static void main(String[] args) { 6 | 7 | int num1=10; 8 | int num2=5; 9 | String operator="*"; 10 | int result=0; 11 | 12 | switch(operator) { 13 | 14 | case "+": 15 | result = num1+num2; 16 | break; 17 | case "-": 18 | result = num1-num2; 19 | break; 20 | case "*": 21 | result = num1*num2; 22 | break; 23 | case "/": 24 | result = num1/num2; 25 | break; 26 | default: 27 | System.out.println("Invalid Operator"); 28 | 29 | } 30 | 31 | System.out.println("Result is " + result); 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/day09_controlFlowStatements_3/IfElseRules.java: -------------------------------------------------------------------------------- 1 | package day09_controlFlowStatements_3; 2 | 3 | public class IfElseRules { 4 | 5 | public static void main(String[] args) { 6 | 7 | if(false) 8 | System.out.println("Hello"); 9 | else 10 | System.out.println("Bye"); 11 | 12 | System.out.println("******************"); 13 | 14 | if(false) 15 | System.out.println("Hello"); 16 | System.out.println("Running"); 17 | //else 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day09_controlFlowStatements_3/SwitchCaseRules.java: -------------------------------------------------------------------------------- 1 | package day09_controlFlowStatements_3; 2 | 3 | public class SwitchCaseRules { 4 | 5 | public static void main(String[] args) { 6 | 7 | final String lastName="Smith"; 8 | String firstName="Mike"; 9 | int id=0; 10 | 11 | 12 | switch(firstName) { 13 | case "Test": 14 | System.out.println("Test"); 15 | break; 16 | case lastName: 17 | id=5; 18 | break; 19 | //case 5: 20 | // break; 21 | } 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day09_controlFlowStatements_3/task37_LaptopModels.java: -------------------------------------------------------------------------------- 1 | package day09_controlFlowStatements_3; 2 | 3 | public class task37_LaptopModels { 4 | 5 | public static void main(String[] args) { 6 | 7 | String computer="Apple"; 8 | 9 | switch(computer) { 10 | case "Apple": 11 | System.out.println("No virus"); 12 | break; 13 | case "Dell": 14 | System.out.println("Tough One"); 15 | break; 16 | case "Acer": 17 | System.out.println("Not recommended"); 18 | break; 19 | default: 20 | System.out.println("Do not buy that one"); 21 | 22 | } 23 | 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/day09_controlFlowStatements_3/task39_TrafficLightSelector.java: -------------------------------------------------------------------------------- 1 | package day09_controlFlowStatements_3; 2 | 3 | public class task39_TrafficLightSelector { 4 | 5 | public static void main(String[] args) { 6 | 7 | char color='r'; 8 | 9 | switch(color) { 10 | case 'R':case 'r': 11 | System.out.println("Red Light"); 12 | break; 13 | case 'O':case 'o': 14 | System.out.println("Orange Light"); 15 | break; 16 | case 'G':case 'g': 17 | System.out.println("Green Light"); 18 | break; 19 | default: 20 | System.out.println("Invalid Light"); 21 | 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day10_controlFlowStatements_4/task40_EvenNumbers.java: -------------------------------------------------------------------------------- 1 | package day10_controlFlowStatements_4; 2 | 3 | public class task40_EvenNumbers { 4 | 5 | public static void main(String[] args) { 6 | 7 | for(int i=1;i<=100;i++) { 8 | 9 | if(i%2==0) { 10 | 11 | System.out.print(i + " "); 12 | } 13 | 14 | 15 | } 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day10_controlFlowStatements_4/task41_OddNumbers.java: -------------------------------------------------------------------------------- 1 | package day10_controlFlowStatements_4; 2 | 3 | public class task41_OddNumbers { 4 | 5 | public static void main(String[] args) { 6 | 7 | for(int i=5;i<=140;i++) { 8 | 9 | if(i%2!=0) { 10 | 11 | System.out.print(i + " "); 12 | } 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/day10_controlFlowStatements_4/task42_SumOfEvenOddNumbers.java: -------------------------------------------------------------------------------- 1 | package day10_controlFlowStatements_4; 2 | 3 | public class task42_SumOfEvenOddNumbers { 4 | 5 | public static void main(String[] args) { 6 | 7 | int sumEven=0; 8 | int sumOdd=0; 9 | 10 | for(int i=1;i<100;i++) { 11 | 12 | if(i%2==0) { 13 | 14 | sumEven=sumEven+i; 15 | 16 | }else { 17 | 18 | sumOdd=sumOdd+i; 19 | 20 | } 21 | } 22 | 23 | System.out.println("Sum of even number " + sumEven); 24 | System.out.println("Sum of odd number " + sumOdd); 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/day10_controlFlowStatements_4/task43_PrintTable.java: -------------------------------------------------------------------------------- 1 | package day10_controlFlowStatements_4; 2 | 3 | public class task43_PrintTable { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | System.out.println("Number NumberSquared"); 9 | System.out.println("------------------------"); 10 | 11 | for(int number=1;number<=10;number++) { 12 | 13 | System.out.println(number + "\t\t" + (number*number)); 14 | 15 | } 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day10_controlFlowStatements_4/task45_RepeatedBiggerNumber.java: -------------------------------------------------------------------------------- 1 | package day10_controlFlowStatements_4; 2 | 3 | public class task45_RepeatedBiggerNumber { 4 | 5 | public static void main(String[] args) { 6 | 7 | int num1=50; 8 | int num2=120; 9 | int repeat=4; 10 | 11 | for(int i=1;i<=repeat;i++) { 12 | 13 | 14 | if(num1>num2) { 15 | System.out.println("Number1 is greater than Num2"); 16 | }else if(num2>num1) { 17 | System.out.println("Number2 is greater than Num1"); 18 | }else if(num1==num2) { 19 | System.out.println("Num1 is equal to Num2"); 20 | } 21 | 22 | 23 | 24 | } 25 | 26 | 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/day10_controlFlowStatements_4/task46_MultiplicationTable.java: -------------------------------------------------------------------------------- 1 | package day10_controlFlowStatements_4; 2 | 3 | public class task46_MultiplicationTable { 4 | 5 | public static void main(String[] args) { 6 | 7 | int num=10; 8 | 9 | System.out.println("Multiplication table for " + num); 10 | System.out.println("--------------------------------"); 11 | 12 | 13 | for(int i=1;i<=10;i++) { 14 | 15 | System.out.println(num + "*" + i + "=" + (num*i)); 16 | } 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/DoWhileLoop.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class DoWhileLoop { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | int i=20; 9 | 10 | do { 11 | 12 | 13 | System.out.println(i); 14 | i++; 15 | 16 | }while(i<=10); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/NestedForLoop.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class NestedForLoop { 4 | 5 | public static void main(String[] args) { 6 | 7 | for(int i=1;i<=5;i++) { 8 | 9 | System.out.println("Outer Loop Iteration " + i); 10 | 11 | for(int j=1;j<=2;j++) { 12 | 13 | System.out.println("i = " + i + "; j = " + j); 14 | 15 | } 16 | 17 | } 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/NestedForLoop2.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class NestedForLoop2 { 4 | 5 | public static void main(String[] args) { 6 | 7 | for(int i=0;i<3;i++) { 8 | 9 | System.out.println("Outer Loop at state: " + i); 10 | 11 | for(int p=0;p<=3;p++) { 12 | 13 | System.out.println("Inner loop at state: " + p); 14 | 15 | if(p==3) { 16 | 17 | System.out.println(); 18 | } 19 | } 20 | } 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/WhileLoop.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class WhileLoop { 4 | 5 | public static void main(String[] args) { 6 | 7 | //print 0-10 8 | 9 | int i=0; 10 | 11 | while(i<=10) { 12 | System.out.println(i); 13 | i++; 14 | } 15 | 16 | //using a loop , iterate untill we have 10 students in the room 17 | 18 | int numberOfStudents=1; 19 | 20 | while(numberOfStudents<=10) { 21 | System.out.println("Student " + numberOfStudents); 22 | numberOfStudents++; 23 | } 24 | 25 | //print 11,10,9,8......1 26 | 27 | int num=11; 28 | while(num>=1) { 29 | System.out.print(num + " "); 30 | num--; 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/task47_Pattern.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class task47_Pattern { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | int rows=6; 9 | int columns=6; 10 | 11 | for(int i=1;i<=rows;i++) { 12 | 13 | for(int j=1;j<=columns;j++) { 14 | 15 | System.out.print("*"); 16 | 17 | } 18 | System.out.println(); 19 | 20 | } 21 | } 22 | 23 | 24 | 25 | 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/task48_Pattern.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class task48_Pattern { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | int rows=7; 9 | 10 | 11 | for(int i=1;i<=rows;i++) { 12 | 13 | for(int j=1;j<=i;j++) { 14 | 15 | System.out.print("*"); 16 | 17 | } 18 | System.out.println(); 19 | 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/task49_pattern.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class task49_pattern { 4 | 5 | public static void main(String[] args) { 6 | 7 | int rows=7; 8 | 9 | 10 | for(int i=1;i<=rows;i++) { 11 | 12 | for(int j=1;j<=i;j++) { 13 | 14 | System.out.print(" "); 15 | 16 | } 17 | 18 | System.out.println("#"); 19 | 20 | } 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/task50_Pattern.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class task50_Pattern { 4 | 5 | public static void main(String[] args) { 6 | 7 | int rows=5; 8 | 9 | 10 | for(int i=1;i<=rows;i++) { 11 | 12 | for(int j=1;j<=i;j++) { 13 | 14 | System.out.print(j + " "); 15 | 16 | } 17 | 18 | System.out.println(); 19 | 20 | } 21 | 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/task52_whileLoop.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class task52_whileLoop { 4 | 5 | public static void main(String[] args) { 6 | 7 | int i=25; 8 | 9 | while(i>10) { 10 | 11 | System.out.println("in the loop"); 12 | 13 | i--; 14 | } 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day11_controlFlowStatements_5/task53_sumOfEvenNumbers.java: -------------------------------------------------------------------------------- 1 | package day11_controlFlowStatements_5; 2 | 3 | public class task53_sumOfEvenNumbers { 4 | 5 | public static void main(String[] args) { 6 | 7 | int i=0; 8 | int sumEven=0; 9 | 10 | while(i<100) { 11 | 12 | if(i%2==0) { 13 | 14 | sumEven = sumEven + i; 15 | } 16 | 17 | i++; 18 | } 19 | 20 | System.out.println(sumEven); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day12_controlFlowStatements_6/BranchingStatements.java: -------------------------------------------------------------------------------- 1 | package day12_controlFlowStatements_6; 2 | 3 | public class BranchingStatements { 4 | 5 | public static void main(String[] args) { 6 | 7 | int number = 0; 8 | 9 | while(number<15) { 10 | 11 | number++; 12 | 13 | if(number<=5) { 14 | 15 | System.out.println("Skipping number " + number); 16 | 17 | continue; 18 | } 19 | 20 | System.out.println("number = " + number); 21 | 22 | if(number>=10) { 23 | 24 | System.out.println("Breaking at " + number); 25 | 26 | break; 27 | } 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/day12_controlFlowStatements_6/BreakContinue.java: -------------------------------------------------------------------------------- 1 | package day12_controlFlowStatements_6; 2 | 3 | public class BreakContinue { 4 | 5 | public static void main(String[] args) { 6 | 7 | for(int i=1;i<=5;i++) { 8 | 9 | if(i==4) { 10 | 11 | //break; 12 | continue; 13 | 14 | } 15 | 16 | System.out.println(i); 17 | } 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day12_controlFlowStatements_6/LabeledStatements.java: -------------------------------------------------------------------------------- 1 | package day12_controlFlowStatements_6; 2 | 3 | public class LabeledStatements { 4 | 5 | public static void main(String[] args) { 6 | 7 | int i=0; 8 | outer: 9 | do { 10 | i=8; 11 | inner: 12 | while(true) { 13 | System.out.println(i--); 14 | if(i==4) { 15 | break outer; 16 | } 17 | } 18 | }while(true); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/CredirCardMethod.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class CredirCardMethod { 4 | 5 | public static void main(String[] args) { 6 | 7 | double salary=50000; 8 | int creditRating=5; 9 | 10 | if(salary>=20000 && creditRating>=7) { 11 | qualify(); 12 | }else { 13 | noQualify(); 14 | } 15 | 16 | 17 | } 18 | 19 | public static void noQualify() { 20 | System.out.println("I am sorry, you are not qualified for the CC "); 21 | } 22 | 23 | public static void qualify() { 24 | System.out.println("Congrat, you are qualified for the CC "); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/DeepAndDeeper.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class DeepAndDeeper { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("I am starting in main"); 8 | deep(); 9 | System.out.println("Now I am back in main"); 10 | 11 | 12 | 13 | 14 | } 15 | 16 | public static void deep() { 17 | System.out.println("I am now in deep"); 18 | deeper(); 19 | System.out.println("Now I am back in deep"); 20 | } 21 | 22 | public static void deeper() { 23 | System.out.println("I am now in deeper"); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/GoogleSearch.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class GoogleSearch { 4 | 5 | public static void main(String[] args) { 6 | 7 | navigateGoogle(); 8 | searchForShoes(); 9 | printResults(); 10 | 11 | } 12 | 13 | public static void navigateGoogle() { 14 | System.out.println("launch chrome browser"); 15 | System.out.println("navigate to google.com"); 16 | } 17 | 18 | public static void searchForShoes() { 19 | System.out.println("type shoes into search field"); 20 | System.out.println("click on search button"); 21 | } 22 | 23 | public static void printResults() { 24 | System.out.println("result for shoes ...."); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/LoopCallMethod.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class LoopCallMethod { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("hello from the main method"); 8 | for(int i=0;i<5;i++) { 9 | displayMessage(); 10 | System.out.println("Back in the main method"); 11 | } 12 | 13 | } 14 | 15 | 16 | public static void displayMessage() { 17 | System.out.println("Hello from displayMessage method"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/PassArg.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class PassArg { 4 | 5 | public static void main(String[] args) { 6 | 7 | double x=10.45; 8 | 9 | displayValue(10); 10 | 11 | displayValue((int)x); 12 | 13 | //displayValue(x*4); 14 | 15 | 16 | 17 | } 18 | 19 | public static void displayValue(int num1) { 20 | 21 | System.out.println("The value is " + num1); 22 | 23 | 24 | } 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/PassMultipleArguments.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class PassMultipleArguments { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | 9 | 10 | 11 | showSum(5,10); 12 | showSum(50,20); 13 | showSum(60,1); 14 | showSum(500,100); 15 | 16 | 17 | } 18 | 19 | public static void showSum(int num1, int num2) { 20 | 21 | System.out.println(num1+num2); 22 | 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/SimpleMethod.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class SimpleMethod { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Hello from main method"); 8 | displayMessage(); 9 | System.out.println("Back in the main method"); 10 | 11 | } 12 | 13 | public static void displayMessage() { 14 | System.out.println("Hello from the method"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/StudentMethod.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class StudentMethod { 4 | 5 | public static void main(String[] args) { 6 | 7 | code(); 8 | sayHello(); 9 | study(); 10 | 11 | } 12 | 13 | 14 | public static void sayHello() { 15 | 16 | System.out.println("Inside sayHello method"); 17 | 18 | } 19 | 20 | public static void code() { 21 | System.out.println("Student is studying"); 22 | } 23 | 24 | public static void study() { 25 | System.out.println("Student is studying java"); 26 | } 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/task56_convertKM.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class task56_convertKM { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | convertKM(); 9 | 10 | 11 | } 12 | 13 | public static void convertKM() { 14 | 15 | int mile=80; 16 | double km=mile * 1.60934; 17 | 18 | System.out.println(mile + " mile = " + km + " km"); 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/task57_sumOfNumbers.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class task57_sumOfNumbers { 4 | 5 | public static void main(String[] args) { 6 | 7 | sumNumbers(); 8 | 9 | 10 | } 11 | 12 | public static void sumNumbers() { 13 | 14 | int num1=10; 15 | int num2=50; 16 | int num3=50; 17 | 18 | int sum=num1+num2+num3; 19 | 20 | System.out.println("Total is " + sum); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/task58_greaterNumber.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class task58_greaterNumber { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | findGreater(); 9 | 10 | } 11 | 12 | public static void findGreater() { 13 | 14 | int num1=50; 15 | int num2=10; 16 | 17 | if(num1>num2) { 18 | System.out.println("num1 is greater"); 19 | }else if(num2>num1) { 20 | System.out.println("num2 is greater"); 21 | }else { 22 | System.out.println("numbers are equal"); 23 | } 24 | } 25 | 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/task59_PayCalculator.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | 4 | public class task59_PayCalculator { 5 | 6 | public static void main(String[] args) { 7 | 8 | payCalculator(80, 20); 9 | payCalculator(37, 62.50); 10 | 11 | } 12 | 13 | public static void payCalculator(double hours,double hourlyPay) { 14 | 15 | double pay = hours * hourlyPay; 16 | 17 | System.out.println(pay); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/task60_calculator.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class task60_calculator { 4 | 5 | public static void main(String[] args) { 6 | 7 | calculator(6, 3, "+"); 8 | calculator(6, 3, "-"); 9 | calculator(6, 3, "*"); 10 | calculator(6, 3, "/"); 11 | 12 | } 13 | 14 | public static void calculator(int num1,int num2,String operator) { 15 | 16 | switch(operator) { 17 | case "+": 18 | System.out.println(num1+num2); 19 | break; 20 | case "-": 21 | System.out.println(num1-num2); 22 | break; 23 | case "*": 24 | System.out.println(num1*num2); 25 | break; 26 | case "/": 27 | System.out.println(num1/num2); 28 | break; 29 | } 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/day13_methods_Part1/task61_AgeCalculator.java: -------------------------------------------------------------------------------- 1 | package day13_methods_Part1; 2 | 3 | public class task61_AgeCalculator { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | ageCalculator(2019, 1965); 9 | ageCalculator(2019, 1875); 10 | 11 | 12 | } 13 | 14 | public static void ageCalculator(int currentYear,int birthyear) { 15 | 16 | int age = currentYear - birthyear; 17 | 18 | System.out.println(age); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day14_methods_Part2/Lab2_Love6.java: -------------------------------------------------------------------------------- 1 | package day14_methods_Part2; 2 | 3 | public class Lab2_Love6 { 4 | 5 | /*The number 6 is a truly great number. Write a method that accepts num1 and num2, 6 | * prints true if either one is 6. Or if their sum or difference is 6. 7 | */ 8 | 9 | 10 | 11 | public static void main(String[] args) { 12 | 13 | love6(6, 4); 14 | love6(4, 5); 15 | love6(1, 5); 16 | love6(12, 6); 17 | 18 | } 19 | 20 | public static void love6(int num1,int num2) { 21 | 22 | if(num1==6 || num2==6 || num1+num2==6 || num1-num2==6 || num2-num1==6) { 23 | System.out.println(true); 24 | }else { 25 | System.out.println(false); 26 | } 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/day14_methods_Part2/ValueReturn.java: -------------------------------------------------------------------------------- 1 | package day14_methods_Part2; 2 | 3 | public class ValueReturn { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | int x = sum(2,3); 9 | 10 | } 11 | 12 | 13 | public static int sum(int num1,int num2) { 14 | 15 | int result; //local variable 16 | result = num1 + num2; 17 | 18 | return result; 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day14_methods_Part2/task66_DistanceTraveled.java: -------------------------------------------------------------------------------- 1 | package day14_methods_Part2; 2 | 3 | public class task66_DistanceTraveled { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | double d = distance(40,5); 9 | 10 | System.out.println(distance(10,5)); 11 | 12 | System.out.println(d); 13 | 14 | if(d>500) { 15 | System.out.println("you spent too much gas"); 16 | }else { 17 | System.out.println("you spent ok gas"); 18 | } 19 | } 20 | 21 | public static double distance(double speed,int time) { 22 | 23 | double distanceTraveled = speed * time; 24 | 25 | return distanceTraveled; 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/day15_methods_Part3/MethodOverloading2.java: -------------------------------------------------------------------------------- 1 | package day15_methods_Part3; 2 | 3 | public class MethodOverloading2 { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | } 9 | 10 | public static int method1(int num1,int num2) { 11 | 12 | return 5; 13 | 14 | 15 | } 16 | 17 | public static double method1(int num1,float num2) { 18 | 19 | return 5.2; 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day15_methods_Part3/assignment1_SwapValue.java: -------------------------------------------------------------------------------- 1 | package day15_methods_Part3; 2 | 3 | public class assignment1_SwapValue { 4 | 5 | public static void main(String[] args) { 6 | 7 | //Solution-1 by using 3rd variable 8 | int n1=10; 9 | int n2=20; 10 | int n3; 11 | 12 | n3=n1; 13 | n1=n2; 14 | n2=n3; 15 | 16 | System.out.println("n1:"+n1); 17 | System.out.println("n2:"+n2); 18 | 19 | //Solution2 without using 3rd variable 20 | 21 | n1=n1+n2; 22 | n2=n1-n2; 23 | n1=n1-n2; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day15_methods_Part3/assignment3_Fibonacci.java: -------------------------------------------------------------------------------- 1 | package day15_methods_Part3; 2 | 3 | public class assignment3_Fibonacci { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | int count=8; 9 | int pre1=0, pre2=1; 10 | System.out.println("Fibonacci series of " + count + " numbers"); 11 | 12 | 13 | for(int i=1;istr2.length()) { 19 | str = str2.concat(str1).concat(str2); 20 | }else { 21 | str = str1.concat(str2).concat(str1); 22 | } 23 | 24 | return str; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day22_stringManipulation_Lab/Question_8.java: -------------------------------------------------------------------------------- 1 | package day22_stringManipulation_Lab; 2 | 3 | public class Question_8 { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println(left2("Hello")); 8 | System.out.println(left2("Java")); 9 | System.out.println(left2("Hi")); 10 | 11 | 12 | } 13 | 14 | public static String left2(String str) { 15 | 16 | return str.substring(2).concat(str.substring(0,2)); 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day22_stringManipulation_Lab/Question_9.java: -------------------------------------------------------------------------------- 1 | package day22_stringManipulation_Lab; 2 | 3 | public class Question_9 { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println(right2("Hello")); 8 | System.out.println(right2("Java")); 9 | 10 | } 11 | 12 | public static String right2(String str) { 13 | 14 | return str.substring(str.length()-2).concat(str.substring(0, str.length()-2)); 15 | 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day22_stringManipulation_Lab/Quetion_10.java: -------------------------------------------------------------------------------- 1 | package day22_stringManipulation_Lab; 2 | 3 | public class Quetion_10 { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println(frontAgain("edited")); 8 | 9 | 10 | } 11 | 12 | public static boolean frontAgain(String str) { 13 | 14 | String first2 = str.substring(0,2); //edited 15 | String last2 = str.substring(str.length()-2); 16 | 17 | return first2.equals(last2); 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day22_stringManipulation_Lab/String_IsEmpty.java: -------------------------------------------------------------------------------- 1 | package day22_stringManipulation_Lab; 2 | 3 | public class String_IsEmpty { 4 | 5 | public static void main(String[] args) { 6 | 7 | String userName = ""; 8 | String password = ""; 9 | 10 | if(userName.isEmpty()) { 11 | System.out.println("Username field can not be empty"); 12 | }else { 13 | System.out.println("Username is not empty"); 14 | } 15 | 16 | 17 | if(userName.isEmpty() || password.isEmpty()) { 18 | System.out.println("Username or password can not be emoty"); 19 | }else { 20 | System.out.println("Username or password is not empty"); 21 | } 22 | 23 | 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/day23_stringManipulationLab_randomClasss/Question_13.java: -------------------------------------------------------------------------------- 1 | package day23_stringManipulationLab_randomClasss; 2 | 3 | public class Question_13 { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | String str = "Hi-there"; //TThhee substring(0,1) substring(1,2) substring(2,3) 9 | 10 | 11 | 12 | 13 | String newString=""; //TThhee 14 | 15 | for(int i=0;i1)) { 17 | return "Array 1 is not valid"; 18 | } 19 | if(!(y.length>1)) { 20 | return "Array 2 is not valid"; 21 | } 22 | 23 | 24 | if(x[0]==y[0] || x[x.length-1]==y[y.length-1]) { 25 | return "true"; 26 | }else { 27 | return "false"; 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/day27_arrays_part4/Loop2DArray.java: -------------------------------------------------------------------------------- 1 | package day27_arrays_part4; 2 | 3 | public class Loop2DArray { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[][] numbers = {{1,2,3},{4,5},{7,8,9}}; 8 | 9 | for(int row=0;rowmax) { 22 | 23 | max = arr[i+1]; 24 | 25 | 26 | } 27 | } 28 | 29 | for(int i=0;imax) { 20 | 21 | max = arr[i]; 22 | } 23 | } 24 | 25 | //finding the smallest 26 | int min = max; 27 | 28 | for(int i=0;icounter4) { 25 | return true; 26 | } 27 | 28 | return false; 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/day29_arrays_Lab/Lab4_Question23.java: -------------------------------------------------------------------------------- 1 | package day29_arrays_Lab; 2 | 3 | import java.util.Arrays; 4 | 5 | public class Lab4_Question23 { 6 | 7 | public static void main(String[] args) { 8 | 9 | System.out.println(Arrays.toString(fizzArray(8))); 10 | } 11 | 12 | public static int[] fizzArray(int x) { 13 | 14 | int[] array = new int[x]; 15 | 16 | for(int i=0;i l1 = new ArrayList<>(); 10 | l1.add("Java"); 11 | l1.add("JS"); 12 | 13 | ArrayList l2 = new ArrayList(); 14 | l2.add("C#"); 15 | l2.add("C++"); 16 | 17 | System.out.println(l1.toString()); 18 | System.out.println(l2.toString()); 19 | 20 | l2.addAll(l1); 21 | System.out.println(l2.toString()); 22 | 23 | l1.addAll(l2); 24 | System.out.println(l1.toString()); 25 | 26 | 27 | 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/day32_arrayList_part2/RemoveAll.java: -------------------------------------------------------------------------------- 1 | package day32_arrayList_part2; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class RemoveAll { 6 | 7 | public static void main(String[] args) { 8 | 9 | ArrayList list1 = new ArrayList<>(); 10 | list1.add(30);list1.add(12);list1.add(22); 11 | 12 | ArrayList list2 = new ArrayList(); 13 | list2.add(30);list2.add(345);list2.add(1);list2.add(12);list2.add(22);list2.add(12); 14 | 15 | System.out.println(list1); 16 | System.out.println(list2); 17 | 18 | //removes all matching values from list1 19 | list2.removeAll(list1); 20 | 21 | System.out.println(list2); 22 | 23 | 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day33_ClassObjects_Constructors/CarTest.java: -------------------------------------------------------------------------------- 1 | package day33_ClassObjects_Constructors; 2 | 3 | public class CarTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Car c1 = new Car(); //it is calling the constructor 8 | //which constrcutor u want me do execute? 9 | //i want to you execute, constructor which does not have any arguments 10 | 11 | Car c2 = new Car("AMG", "Mercedes", 2007, 65000, "White"); 12 | Car c3 = new Car("Corolla", "Toyota", 2015, 32000, "Yellow"); 13 | Car c4 = new Car("Altima", "Nisssan", 2014, 41000, "Black"); 14 | 15 | 16 | 17 | 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day33_ClassObjects_Constructors/MouseTest.java: -------------------------------------------------------------------------------- 1 | package day33_ClassObjects_Constructors; 2 | 3 | public class MouseTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Mouse mouse = new Mouse(15); 8 | 9 | 10 | 11 | mouse.print(); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/day33_ClassObjects_Constructors/Rectangle.java: -------------------------------------------------------------------------------- 1 | package day33_ClassObjects_Constructors; 2 | 3 | public class Rectangle { 4 | 5 | double length; 6 | double width; 7 | 8 | 9 | public void getArea() { 10 | System.out.println(length * width); 11 | } 12 | 13 | 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/day33_ClassObjects_Constructors/RectangleTest.java: -------------------------------------------------------------------------------- 1 | package day33_ClassObjects_Constructors; 2 | 3 | public class RectangleTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Rectangle r1 = new Rectangle(); 8 | 9 | r1.length=5.2; 10 | r1.width=4.8; 11 | 12 | 13 | 14 | Rectangle r2 = new Rectangle(); 15 | r2.length=3.5; 16 | r2.width=2.7; 17 | 18 | 19 | System.out.println(r1.length); 20 | System.out.println(r2.width); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day33_ClassObjects_Constructors/StudentTest.java: -------------------------------------------------------------------------------- 1 | package day33_ClassObjects_Constructors; 2 | 3 | public class StudentTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Student s1 = new Student("Mike", 17, 'M', 2019, "Java"); 8 | Student s2 = new Student("Mary", 25, 'F', 2017, "JS"); 9 | 10 | System.out.println(s1.university); 11 | System.out.println(s2.university); 12 | 13 | s1.attendLab(); 14 | s2.attendLecture(); 15 | 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day34_Constructors/Apple.java: -------------------------------------------------------------------------------- 1 | package day34_Constructors; 2 | 3 | public class Apple { 4 | 5 | //instance variable 6 | String color = "Red"; 7 | 8 | public void mA() { 9 | System.out.println(color); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/day34_Constructors/AppleTest.java: -------------------------------------------------------------------------------- 1 | package day34_Constructors; 2 | 3 | public class AppleTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Apple a1 = new Apple(); 8 | 9 | changeApple(a1); 10 | 11 | System.out.println(a1.color); 12 | 13 | System.out.println(methodObject().color); 14 | 15 | 16 | 17 | } 18 | 19 | public static void changeApple(Apple x) { 20 | x.color = "White"; 21 | } 22 | 23 | public static Apple methodObject(){ 24 | 25 | Apple b1 = new Apple(); 26 | return b1; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/day34_Constructors/Dice.java: -------------------------------------------------------------------------------- 1 | package day34_Constructors; 2 | 3 | import java.util.Random; 4 | 5 | public class Dice { 6 | 7 | int sides; 8 | int value; 9 | 10 | public Dice(int numSides) { 11 | sides=numSides; 12 | roll(); 13 | } 14 | 15 | public void roll() { 16 | Random rand = new Random(); 17 | value=rand.nextInt(sides) + 1; 18 | } 19 | 20 | public int getSides() { 21 | return sides; 22 | } 23 | 24 | public int getValue() { 25 | return value; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/day34_Constructors/DiceTest.java: -------------------------------------------------------------------------------- 1 | package day34_Constructors; 2 | 3 | public class DiceTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | final int SIX_SIDES=6; 9 | Dice sixDice = new Dice(SIX_SIDES); 10 | 11 | rollDice(sixDice); 12 | } 13 | 14 | public static void rollDice(Dice d) { 15 | //Rolling a 6 sided dice 16 | System.out.println("Rolling a " + d.getSides() + " sided dice "); 17 | 18 | //The dice's value : 5 19 | System.out.println("The dice's value : " + d.getValue()); 20 | } 21 | 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day34_Constructors/LigthTest.java: -------------------------------------------------------------------------------- 1 | package day34_Constructors; 2 | 3 | public class LigthTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Light l1 = new Light(); 8 | 9 | 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/day35_encapsulation/CarpetTest.java: -------------------------------------------------------------------------------- 1 | package day35_encapsulation; 2 | 3 | public class CarpetTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | /* 8 | Floor f = new Floor(10,20); 9 | Carpet c = new Carpet(5.2); 10 | 11 | Calculator cal = new Calculator(f,c); 12 | 13 | System.out.println(cal.getTotalCost()); 14 | */ 15 | 16 | Calculator cal = new Calculator(new Floor(10,20), new Carpet(5.2)); 17 | System.out.println(cal.getTotalCost()); 18 | 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day35_encapsulation/PerseonTest.java: -------------------------------------------------------------------------------- 1 | package day35_encapsulation; 2 | 3 | public class PerseonTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Person ozzy = new Person(); 8 | 9 | ozzy.setAge(18); 10 | 11 | //print age 12 | System.out.println(ozzy.getAge()); 13 | 14 | 15 | //Encapsulation 16 | 17 | //cut the access - private 18 | //create setter method to initialize my value 19 | //create getter method to retrive it 20 | 21 | 22 | //private variables 23 | //public setter methods 24 | //public getter methods 25 | 26 | 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/day35_encapsulation/Person.java: -------------------------------------------------------------------------------- 1 | package day35_encapsulation; 2 | 3 | public class Person { 4 | 5 | private String name; 6 | private int age; 7 | private char gender; 8 | 9 | public void setAge(int age) { 10 | this.age = age; 11 | } 12 | 13 | public String getName() { 14 | return name; 15 | } 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | public int getAge() { 20 | return age; 21 | } 22 | 23 | public char getGender() { 24 | return gender; 25 | } 26 | public void setGender(char gender) { 27 | this.gender = gender; 28 | } 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/day35_encapsulation/PrinterTest.java: -------------------------------------------------------------------------------- 1 | package day35_encapsulation; 2 | 3 | public class PrinterTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Printer printer = new Printer(50, false); 8 | System.out.println("initial page count = " +printer.getPagesPrinted()); 9 | int pagesPrinted = printer.printPages(4); 10 | System.out.println("Pages printed was " + pagesPrinted +" new total print count for printer = " +printer.getPagesPrinted()); 11 | pagesPrinted = printer.printPages(2); 12 | System.out.println("Pages printed was " + pagesPrinted +" new total print count for printer = " +printer.getPagesPrinted()); 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day35_encapsulation/RoulettePocketTest.java: -------------------------------------------------------------------------------- 1 | package day35_encapsulation; 2 | 3 | import java.util.Scanner; 4 | 5 | public class RoulettePocketTest { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner sc = new Scanner(System.in); 10 | 11 | System.out.println("Enter your pocket number:"); 12 | 13 | RoulettePocket rp = new RoulettePocket(sc.nextInt()); 14 | 15 | while(rp.getPocketColor().equalsIgnoreCase("invalid")) { 16 | System.out.println("Enter your pocket number:"); 17 | rp.setPocketNumber(sc.nextInt()); 18 | } 19 | 20 | System.out.println(rp.getPocketColor()); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/ABC.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class ABC { 4 | 5 | private ABC() { 6 | 7 | } 8 | 9 | public static void m1() {} 10 | 11 | public static void m2() {} 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/ABCTest.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class ABCTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | ABC.m1(); //no error 8 | 9 | //ABC o1 = new ABC(); //error 10 | //o1.m1(); 11 | 12 | //whenever all of your methods in your class are static, 13 | //and you want everyone to call them static way - ClassName.methodname(), 14 | //then you can simply make your constructor private 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/AllBlocks.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class AllBlocks { 4 | 5 | public AllBlocks(int x) { 6 | System.out.println("One Argument Constructor"); 7 | } 8 | 9 | public AllBlocks() { 10 | System.out.println("No argument constructor"); 11 | } 12 | 13 | static { 14 | System.out.println("Firsrt Static Init"); 15 | } 16 | 17 | { 18 | System.out.println("First Instnce Init"); 19 | } 20 | 21 | { 22 | System.out.println("Second Instance Init"); 23 | } 24 | 25 | static{ 26 | System.out.println("Second Static Init"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/AllBlocksTest.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class AllBlocksTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | //run static blocks - 1 time 8 | 9 | //run all instance blocoks 10 | AllBlocks o1 = new AllBlocks(); 11 | 12 | //run all instance blocks 13 | AllBlocks o2 = new AllBlocks(8); 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/Calculator.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class Calculator { 4 | 5 | int x; 6 | 7 | public static double plus(double num1,double num2) { 8 | return num1+num2; 9 | } 10 | 11 | public static double minus(double num1,double num2) { 12 | return num1-num2; 13 | } 14 | 15 | public static double multiply(double num1,double num2) { 16 | return num1*num2; 17 | } 18 | 19 | public int m1() { 20 | return x+4; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/CalculatorTest.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class CalculatorTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Calculator c1 = new Calculator(); 8 | System.out.println(c1.plus(2, 4)); 9 | 10 | System.out.println(Calculator.plus(2, 4)); 11 | 12 | int i = Integer.parseInt("33"); 13 | System.out.println(Character.isDigit('4')); 14 | 15 | //1 16 | CalculatorTest.mA(); 17 | //2 18 | CalculatorTest ct = new CalculatorTest(); 19 | ct.mA(); 20 | //3 21 | mA(); 22 | 23 | 24 | } 25 | 26 | public static void mA() { 27 | System.out.println("Hello"); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/Campus.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class Campus { 4 | 5 | private String city; 6 | 7 | static String country; 8 | 9 | static { 10 | System.out.println("Static Block-1"); 11 | country="USA"; 12 | } 13 | 14 | public Campus(String city) { 15 | System.out.println("Constructor"); 16 | this.city=city; 17 | } 18 | 19 | static { 20 | System.out.println("Static Block-2"); 21 | country="UK"; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/CampusTest.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class CampusTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | 9 | Campus c1 = new Campus("McLean"); 10 | Campus c2 = new Campus("Arlington"); 11 | 12 | System.out.println(Campus.country); 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/Car.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class Car { 4 | 5 | int door; 6 | 7 | public static void run() { 8 | System.out.println("Car is running"); 9 | } 10 | 11 | public int getDoorNumber() { 12 | return door+2; 13 | } 14 | 15 | } 16 | 17 | class CarTest{ 18 | 19 | public static void main(String[] args) { 20 | 21 | Car c = new Car(); 22 | c.run(); 23 | 24 | Car.run(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/Countable.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class Countable { 4 | 5 | static int instanceCount; //instance vriable 6 | int instanceCount2; 7 | 8 | public Countable() { 9 | instanceCount++; 10 | } 11 | 12 | public int getInstanceCount() { 13 | return instanceCount; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/CountableTest.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class CountableTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | int objectCount; 9 | 10 | Countable o1 = new Countable(); 11 | Countable o2 = new Countable(); 12 | Countable o3 = new Countable(); 13 | /* 14 | objectCount = o1.getInstanceCount(); 15 | objectCount = o2.getInstanceCount(); 16 | objectCount = o3.getInstanceCount(); 17 | */ 18 | 19 | System.out.println(o2.getInstanceCount()); 20 | 21 | System.out.println(Countable.instanceCount); 22 | 23 | 24 | 25 | 26 | 27 | } 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/Dinner.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class Dinner { 4 | 5 | static int pizzaSlice = 8; 6 | 7 | public void takeASlice() { 8 | pizzaSlice--; 9 | } 10 | 11 | public void takeASlice(int count) { 12 | pizzaSlice-=count; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/DinnerTest.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class DinnerTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Dinner mom = new Dinner(); 8 | Dinner kid = new Dinner(); 9 | Dinner dad = new Dinner(); 10 | 11 | System.out.println("Total Slices:" + Dinner.pizzaSlice); 12 | 13 | dad.takeASlice(); 14 | kid.takeASlice(); 15 | mom.takeASlice(); 16 | 17 | System.out.println("Total Slices:" + Dinner.pizzaSlice); 18 | 19 | kid.takeASlice(3); 20 | dad.takeASlice(2); 21 | 22 | //mom.takeASlice(); 23 | 24 | System.out.println("Total Slices:" + Dinner.pizzaSlice); 25 | 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/StaticImport.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | import static java.lang.Math.*; //packageName.className.elements(variables or methods) 4 | 5 | import java.util.*; //packageName.className 6 | 7 | public class StaticImport { 8 | 9 | public static void main(String[] args) { 10 | 11 | 12 | 13 | System.out.println(Math.sqrt(16)); 14 | 15 | System.out.println(sqrt(16)); 16 | 17 | System.out.println(PI); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/Student.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class Student { 4 | 5 | String name; 6 | int age; 7 | int idNumber; 8 | static String school="Cybertek"; 9 | 10 | public Student(String name, int age, int idNumber) { 11 | this.name = name; 12 | this.age = age; 13 | this.idNumber = idNumber; 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return "Student [name=" + name + ", age=" + age + ", idNumber=" + idNumber + ", school=" + school + "]"; 19 | } 20 | 21 | 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day36_staticClassMembers/StudentTest.java: -------------------------------------------------------------------------------- 1 | package day36_staticClassMembers; 2 | 3 | public class StudentTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Student s1 = new Student("Mike",30,1000); 8 | Student s2 = new Student("Ozzy",20,2000); 9 | Student s3 = new Student("Jamal",10,3000); 10 | 11 | s1.school="CybertekEU"; 12 | //whenever i make changes, this change is reflected in class level 13 | //so all other object will be affected thru this change 14 | 15 | 16 | System.out.println(s1.toString()); 17 | System.out.println(s2.toString()); 18 | System.out.println(s3.toString()); 19 | 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day37_inheritance/Company.java: -------------------------------------------------------------------------------- 1 | package day37_inheritance; 2 | 3 | public class Company { 4 | 5 | public static void main(String[] args) { 6 | 7 | Employee emp1 = new Employee(); 8 | 9 | emp1.name = "Tom"; 10 | emp1.jobTitle = "SDET"; 11 | emp1.age = 27; 12 | emp1.gender = 'M'; 13 | 14 | emp1.work(); 15 | 16 | emp1.eat("Salad"); 17 | 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day37_inheritance/Employee.java: -------------------------------------------------------------------------------- 1 | package day37_inheritance; 2 | 3 | public class Employee extends Person{ 4 | 5 | String jobTitle; 6 | 7 | public void work() { 8 | System.out.println(name + " is working as " + jobTitle); 9 | } 10 | 11 | @Override 12 | public String toString() { 13 | return "Employee [jobTitle=" + jobTitle + ", name=" + name + ", age=" + age + ", gender=" + gender + "]"; 14 | } 15 | 16 | 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day37_inheritance/FinalExam.java: -------------------------------------------------------------------------------- 1 | package day37_inheritance; 2 | 3 | public class FinalExam extends GradeActivity { 4 | 5 | private int numQuestions; 6 | private double pointsEach; 7 | private int numMissed; 8 | 9 | 10 | public FinalExam(int numQuestions,int numMissed) { 11 | 12 | double numericScore; 13 | 14 | this.numQuestions = numQuestions; 15 | this.numMissed = numMissed; 16 | 17 | pointsEach = 100.0 / numQuestions; 18 | numericScore = 100.0 - (numMissed * pointsEach); 19 | 20 | 21 | //My goal is to receive the letter based on my numericScore 22 | //how will I set my numericScore to score 23 | 24 | 25 | setScore(numericScore); 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/day37_inheritance/GradeActivity.java: -------------------------------------------------------------------------------- 1 | package day37_inheritance; 2 | 3 | public class GradeActivity { 4 | 5 | private double score; 6 | 7 | public double getScore() { 8 | return score; 9 | } 10 | 11 | public void setScore(double score) { 12 | this.score = score; 13 | } 14 | 15 | public char getGrade() { 16 | 17 | char letterGrade; 18 | 19 | if(score>=90) { 20 | letterGrade = 'A'; 21 | }else if(score>=80) { 22 | letterGrade = 'B'; 23 | }else if(score>=70) { 24 | letterGrade = 'C'; 25 | }else if(score>=60) { 26 | letterGrade = 'D'; 27 | }else { 28 | letterGrade = 'F'; 29 | } 30 | 31 | return letterGrade; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/day37_inheritance/Person.java: -------------------------------------------------------------------------------- 1 | package day37_inheritance; 2 | 3 | public class Person { 4 | 5 | String name; 6 | int age; 7 | char gender; 8 | 9 | public void eat(String food) { 10 | System.out.println(name + " is eating " + food); 11 | } 12 | 13 | public void walk() { 14 | System.out.println(name + " is walking"); 15 | } 16 | 17 | public void sleep(int hours) { 18 | System.out.println(name + " is sleeping for " + hours + " hours"); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day37_inheritance/School.java: -------------------------------------------------------------------------------- 1 | package day37_inheritance; 2 | 3 | public class School { 4 | 5 | public static void main(String[] args) { 6 | 7 | Person person = new Person(); 8 | person.name = "Mike"; 9 | person.age = 40; 10 | person.gender = 'M'; 11 | 12 | Student student = new Student(); 13 | student.name = "Tom"; //assign Tom to name. where is name? what is object? student - belong to Student class 14 | student.age = 25; 15 | student.gender = 'M'; 16 | student.studentId = 12948; 17 | 18 | 19 | 20 | 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day37_inheritance/Student.java: -------------------------------------------------------------------------------- 1 | package day37_inheritance; 2 | 3 | public class Student extends Person { //student can have everything person class has 4 | 5 | int studentId; 6 | String termClass; 7 | 8 | public void code(String lang) { 9 | System.out.println(name + " is coding " + lang); 10 | } 11 | 12 | public void attendClass() { 13 | System.out.println(name + " is attending " + termClass + " class"); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/Car.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class Car extends Vehicle { 4 | 5 | int maxSpeed = 180; 6 | 7 | public void display() { 8 | System.out.println("maximum speed:" + super.maxSpeed); 9 | System.out.println("maximum speed:" + maxSpeed); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/CarTest.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class CarTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Car c1 = new Car(); 8 | c1.display(); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/CompanyTest.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class CompanyTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Employee emp = new Employee(); 8 | FullTimeEmployee ft = new FullTimeEmployee(); 9 | Contractor ct = new Contractor(); 10 | 11 | emp.calculatePay(40, 40); 12 | ft.calculatePay(40, 40); 13 | ct.calculatePay(40, 40); 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/ConstructorTest.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class ConstructorTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | SubClass obj = new SubClass(); 8 | 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/Contractor.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class Contractor extends Employee { 4 | 5 | @Override 6 | void calculatePay(int hours, double rate) { 7 | double total = (hours * rate)+200; 8 | System.out.println("Contractor Total Pay:" + total); 9 | } 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/DogTest.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class DogTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | //who is job in java to init variables 9 | Dog d = new Dog(2, 4, 1, 20, "Long Silky"); 10 | 11 | //print name 12 | System.out.println(d.getName()); 13 | 14 | 15 | 16 | 17 | 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/Employee.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class Employee { 4 | 5 | void calculatePay(int hours,double rate) { 6 | System.out.println("Employee total pay:" + (hours * rate)); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/FullTimeEmployee.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class FullTimeEmployee extends Employee { 4 | 5 | @Override 6 | void calculatePay(int hours, double rate) { 7 | double total = (hours * rate)*1.05; 8 | System.out.println("FullTime Emplyee Total Pay:" + total); 9 | } 10 | 11 | 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/Person.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class Person { 4 | 5 | public void message() { 6 | System.out.println("This is person classs"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/StaticSub.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class StaticSub extends StaticSuper { 4 | 5 | public void print() { 6 | System.out.println(num); 7 | } 8 | 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/StaticSuper.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class StaticSuper { 4 | 5 | public static int num; 6 | 7 | public static void m1() { 8 | System.out.println("StaticSuper.m1() called"); 9 | } 10 | 11 | public void m2() { 12 | System.out.println("StaticSuper.m2() called"); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/StaticTest.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class StaticTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | StaticSub obj = new StaticSub(); 8 | obj.num = 5; 9 | obj.print(); 10 | 11 | StaticSuper.num = 10; 12 | 13 | obj.print(); 14 | 15 | System.out.println(StaticSub.num); 16 | 17 | //StaticSub.m2(); 18 | 19 | obj.m2(); 20 | 21 | StaticSub.m1(); 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/Student.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class Student extends Person { 4 | 5 | @Override 6 | public void message() { 7 | System.out.println("This is student class"); 8 | } 9 | 10 | public void display() { 11 | message(); 12 | super.message(); 13 | } 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/SubClass.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class SubClass extends SuperClass { 4 | 5 | public SubClass() { 6 | 7 | System.out.println("This is the subclass constructor"); 8 | } 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/SuperClass.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class SuperClass { 4 | 5 | public SuperClass() { 6 | 7 | System.out.println("This is the super class Constructor"); 8 | 9 | } 10 | 11 | 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/day38_inheritance_part2/Vehicle.java: -------------------------------------------------------------------------------- 1 | package day38_inheritance_part2; 2 | 3 | public class Vehicle { 4 | 5 | int maxSpeed = 120; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/day39_inheritance_review/ToyotaTest.java: -------------------------------------------------------------------------------- 1 | package day39_inheritance_review; 2 | 3 | public class ToyotaTest { 4 | 5 | public static void main(String args[]) { 6 | 7 | Toyota toyota = new Toyota(36); 8 | 9 | toyota.steer(45); 10 | toyota.accelerate(30); 11 | toyota.accelerate(20); 12 | toyota.accelerate(-42); 13 | } 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/Car.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class Car { 4 | 5 | public String model; 6 | public int year; 7 | private int door; 8 | protected double engine; 9 | 10 | 11 | @Override 12 | public String toString() { 13 | return "Car [model=" + model + ", year=" + year + ", door=" + door + ", engine=" + engine + "]"; 14 | } 15 | 16 | 17 | 18 | 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/CarTest.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class CarTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Car c = new Car(); 8 | c.model = "m3"; 9 | c.year = 2017; 10 | //c.door = 4; //private 11 | c.engine = 5.2; 12 | 13 | System.out.println(c.toString()); 14 | 15 | 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/Child.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class Child extends Parent { 4 | 5 | public int x = 200; 6 | 7 | 8 | 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/FinalArray.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class FinalArray { 4 | 5 | public static void main(String[] args) { 6 | 7 | final int[] TEAMS = {11,10}; 8 | System.out.println(TEAMS[0]); 9 | 10 | TEAMS[0] = 15; 11 | System.out.println(TEAMS[0]); 12 | 13 | int[] nums = new int[] {20,20,40}; 14 | nums = new int[] {30,30,50}; 15 | 16 | final int[] finalNums = {23,66,77}; 17 | finalNums[0] = 120; 18 | 19 | //finalNums = new int[] {1,2,3}; 20 | 21 | 22 | 23 | 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/FinalArrayList.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class FinalArrayList { 6 | 7 | public static void main(String[] args) { 8 | 9 | final ArrayList COLORS = new ArrayList<>(); 10 | 11 | COLORS.add("Orange"); 12 | COLORS.add("Red"); 13 | COLORS.remove(0); 14 | 15 | //COLORS = new ArrayList(); 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/FinalMethods.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class FinalMethods { 4 | 5 | public final void method1() { 6 | System.out.println("Method-1"); 7 | 8 | String x = "Apple"; 9 | } 10 | 11 | public final static void staticMethod(String word) { 12 | System.out.println("Static Method"); 13 | } 14 | 15 | } 16 | 17 | 18 | class Sub extends FinalMethods{ 19 | 20 | /* 21 | public void method1() { 22 | System.out.println("Method-1 in subclass"); 23 | } 24 | 25 | public static void staticMethod(String word) { 26 | System.out.println("Static Method in Sub Class"); 27 | } 28 | */ 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/Kangaroo.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class Kangaroo extends Marsupial { 4 | 5 | /* 6 | @Override 7 | public boolean isBiped() { 8 | return true; 9 | } 10 | */ 11 | 12 | 13 | public static boolean isBiped() { 14 | return true; 15 | } 16 | 17 | 18 | public void getKangarooDescription() { 19 | System.out.println("Kangaroo hops on two legs:" + isBiped()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/KangarooTest.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class KangarooTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Kangaroo k = new Kangaroo(); 8 | k.getMarsupialDescription(); 9 | 10 | k.getKangarooDescription(); 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/Marsupial.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class Marsupial { 4 | 5 | /* 6 | public boolean isBiped() { 7 | return false; 8 | } 9 | */ 10 | 11 | 12 | 13 | public static boolean isBiped() { 14 | return false; 15 | } 16 | 17 | 18 | public void getMarsupialDescription() { 19 | System.out.println("Marsupial walks on the two legs:" + isBiped()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/Mouse.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class Mouse extends Rodent { 4 | 5 | protected int tailLength = 8; 6 | 7 | public void getMouseDetails() { 8 | System.out.println("tail:" + tailLength + ",parentTail:" + super.tailLength); 9 | } 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/Parent.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class Parent { 4 | 5 | public int x = 100; 6 | 7 | public void increment() { 8 | x++; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/Rodent.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class Rodent { 4 | 5 | protected int tailLength = 4; 6 | 7 | public void getRodentDetails() { 8 | System.out.println("parentTail:" + tailLength); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/TestMouse.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class TestMouse { 4 | 5 | public static void main(String[] args) { 6 | 7 | Mouse mouse = new Mouse(); 8 | 9 | mouse.getMouseDetails(); 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final/TestParentChild.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final; 2 | 3 | public class TestParentChild { 4 | 5 | public static void main(String[] args) { 6 | 7 | Child s = new Child(); 8 | System.out.println("Value of x before increment " + s.x); 9 | 10 | s.increment(); 11 | System.out.println("Value of x after increment " + s.x); 12 | 13 | Parent p = new Parent(); 14 | System.out.println("Value of x before increment " + p.x); 15 | 16 | p.increment(); 17 | System.out.println("Value of x after increment " + p.x); 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final_2/Car2.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final_2; 2 | 3 | import day40_accessmodifiers_final.Car; 4 | 5 | public class Car2 extends Car { 6 | 7 | public Car2() { 8 | 9 | //model = "M3"; 10 | year = 2017; 11 | //door = 4; 12 | engine = 5.2; 13 | 14 | } 15 | 16 | 17 | 18 | } -------------------------------------------------------------------------------- /src/day40_accessmodifiers_final_2/CarTest.java: -------------------------------------------------------------------------------- 1 | package day40_accessmodifiers_final_2; 2 | 3 | import java.util.Scanner; 4 | 5 | import day40_accessmodifiers_final.Car; 6 | 7 | public class CarTest { 8 | 9 | public static void main(String[] args) { 10 | 11 | Car c = new Car(); 12 | 13 | //c.model = "M3"; 14 | c.year = 2017; 15 | //c.door = 4; 16 | //c.engine = 5.2; 17 | 18 | 19 | 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day41_abstract_class/Bird.java: -------------------------------------------------------------------------------- 1 | package day41_abstract_class; 2 | 3 | public abstract class Bird extends Animal { 4 | 5 | 6 | @Override 7 | void eat() { 8 | System.out.println("Bird is eating"); 9 | 10 | } 11 | 12 | /* 13 | 14 | @Override 15 | void breathe() { 16 | // TODO Auto-generated method stub 17 | 18 | } 19 | */ 20 | 21 | abstract void fly(); 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day41_abstract_class/Dog.java: -------------------------------------------------------------------------------- 1 | package day41_abstract_class; 2 | 3 | public class Dog extends Animal{ 4 | 5 | 6 | @Override 7 | void eat() { 8 | System.out.println("Dog food"); 9 | } 10 | 11 | 12 | @Override 13 | void breathe() { 14 | // TODO Auto-generated method stub 15 | 16 | } 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day41_abstract_class/Parrot.java: -------------------------------------------------------------------------------- 1 | package day41_abstract_class; 2 | 3 | public class Parrot extends Bird { 4 | 5 | @Override 6 | void fly() { 7 | // TODO Auto-generated method stub 8 | 9 | } 10 | 11 | @Override 12 | void breathe() { 13 | // TODO Auto-generated method stub 14 | 15 | } 16 | 17 | String x = "apple"; 18 | 19 | 20 | 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day42_interface/Car.java: -------------------------------------------------------------------------------- 1 | package day42_interface; 2 | 3 | @FunctionalInterface 4 | public interface Car { 5 | 6 | void mA(); 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/day42_interface/Electric.java: -------------------------------------------------------------------------------- 1 | package day42_interface; 2 | 3 | public interface Electric { 4 | 5 | public static final boolean HAS_BATTERIES=true; 6 | 7 | boolean HAS_BATTERIES2=false; //public static final 8 | 9 | public abstract void charge(); 10 | 11 | void charge2(); //public abstract 12 | 13 | public default void methodA() { 14 | //code 15 | } 16 | 17 | public static void methodB() { 18 | //code 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day42_interface/ElectricTruck.java: -------------------------------------------------------------------------------- 1 | package day42_interface; 2 | 3 | public abstract class ElectricTruck extends ElectricCar { 4 | 5 | public ElectricTruck(String model, double price, String color) { 6 | super(model, price, color); 7 | } 8 | 9 | abstract void load(String item); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day42_interface/SelfDriving.java: -------------------------------------------------------------------------------- 1 | package day42_interface; 2 | 3 | public interface SelfDriving { 4 | 5 | void selfDrive(); 6 | 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/day42_interface/Tesla.java: -------------------------------------------------------------------------------- 1 | package day42_interface; 2 | 3 | public class Tesla extends ElectricCar { 4 | 5 | public Tesla(String model, double price, String color) { 6 | super(model, price, color); 7 | 8 | } 9 | 10 | @Override 11 | void start() { 12 | System.out.println("tesla is starting"); 13 | System.out.println("change to drive mode."); 14 | 15 | } 16 | 17 | @Override 18 | void charge() { 19 | System.out.println("Tesla charging - plugin to electric outlet..."); 20 | 21 | } 22 | 23 | @Override 24 | void drive() { 25 | System.out.println("Tesla is driving"); 26 | 27 | } 28 | 29 | 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/day42_interface/Tesla2.java: -------------------------------------------------------------------------------- 1 | package day42_interface; 2 | 3 | public class Tesla2 extends Vehicle implements Electric,SelfDriving { 4 | 5 | 6 | 7 | @Override 8 | public void charge2() { 9 | // TODO Auto-generated method stub 10 | 11 | } 12 | 13 | @Override 14 | public void selfDrive() { 15 | // TODO Auto-generated method stub 16 | 17 | } 18 | 19 | @Override 20 | public void charge() { 21 | // TODO Auto-generated method stub 22 | 23 | } 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day42_interface/TeslaTruck.java: -------------------------------------------------------------------------------- 1 | package day42_interface; 2 | 3 | public class TeslaTruck extends TeslaSemi { 4 | 5 | public TeslaTruck(String model, double price, String color, double engineSize) { 6 | super(model, price, color, engineSize); 7 | } 8 | 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day42_interface/Vehicle.java: -------------------------------------------------------------------------------- 1 | package day42_interface; 2 | 3 | public class Vehicle { 4 | 5 | void drive() { 6 | System.out.println("Vehicle is driving"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/day43_polymorphism/Circle.java: -------------------------------------------------------------------------------- 1 | package day43_polymorphism; 2 | 3 | public class Circle extends Shape { 4 | 5 | public void draw() { 6 | System.out.println("Drawing a circle"); 7 | } 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/day43_polymorphism/InstanceOf.java: -------------------------------------------------------------------------------- 1 | package day43_polymorphism; 2 | 3 | public class InstanceOf { 4 | 5 | public static void main(String[] args) { 6 | 7 | Shape sh = new Triangle(); 8 | 9 | if(sh instanceof Triangle) { 10 | System.out.println("Triangle Class"); 11 | }else if(sh instanceof Circle) { 12 | System.out.println("Circle Class"); 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/day43_polymorphism/Shape.java: -------------------------------------------------------------------------------- 1 | package day43_polymorphism; 2 | 3 | public class Shape { 4 | 5 | public void draw() { 6 | System.out.println("Drawing a shape"); 7 | } 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/day43_polymorphism/ShapesArray.java: -------------------------------------------------------------------------------- 1 | package day43_polymorphism; 2 | 3 | public class ShapesArray { 4 | 5 | public static void main(String[] args) { 6 | 7 | Shape[] shapes = new Shape[3]; 8 | 9 | shapes[0] = new Square(); 10 | shapes[1] = new Triangle(); 11 | shapes[2] = new Circle(); 12 | 13 | for(Shape sh : shapes) { 14 | //System.out.println(sh.getClass().getName()); 15 | System.out.println(sh.getClass().getSimpleName()); 16 | //sh.draw(); 17 | } 18 | 19 | 20 | 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day43_polymorphism/Square.java: -------------------------------------------------------------------------------- 1 | package day43_polymorphism; 2 | 3 | public class Square extends Shape { 4 | 5 | @Override 6 | public void draw() { 7 | System.out.println("Drawing a square"); 8 | } 9 | 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/day43_polymorphism/TestAnimal.java: -------------------------------------------------------------------------------- 1 | package day43_polymorphism; 2 | 3 | public class TestAnimal { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | Animal animal = new Animal(); 9 | 10 | Animal dog = new Dog(); 11 | 12 | Animal bird = new Bird(); 13 | 14 | animal = new Cat(); 15 | 16 | //Bird bird2 = new Animal(); 17 | 18 | } 19 | 20 | } 21 | 22 | class Animal{} 23 | 24 | class Dog extends Animal{} 25 | 26 | class Bird extends Animal{} 27 | 28 | class Cat extends Animal{} 29 | 30 | -------------------------------------------------------------------------------- /src/day43_polymorphism/TestShape.java: -------------------------------------------------------------------------------- 1 | package day43_polymorphism; 2 | 3 | public class TestShape { 4 | 5 | public static void main(String[] args) { 6 | 7 | Shape s1 = new Shape(); 8 | s1.draw(); 9 | 10 | Shape s2 = new Circle(); 11 | s2.draw(); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/day43_polymorphism/Triangle.java: -------------------------------------------------------------------------------- 1 | package day43_polymorphism; 2 | 3 | public class Triangle extends Shape { 4 | 5 | @Override 6 | public void draw() { 7 | System.out.println("Drawing a triangle"); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/day44_oopreview/callcenter/ScreenSharable.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.callcenter; 2 | 3 | public interface ScreenSharable { 4 | 5 | void ShareScreen(); //public abstract void ShareScreen(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/day44_oopreview/callcenter/VideoCallable.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.callcenter; 2 | 3 | public interface VideoCallable { 4 | 5 | void videoCall(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/day44_oopreview/callcenter/VideoMessagingApp.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.callcenter; 2 | 3 | public abstract class VideoMessagingApp extends MessagingApp implements ScreenSharable,VideoCallable { 4 | 5 | 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/day44_oopreview/callcenter/VoiceCallable.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.callcenter; 2 | 3 | public interface VoiceCallable { 4 | 5 | boolean CAN_CALL = true; //public static final boolean CAN_CALL=true; 6 | 7 | //abstract method 8 | void call(String contact); //public abstract void call(String contact) 9 | 10 | //static method 11 | public static void decline(){ 12 | System.out.println("Mike declined voice call.."); 13 | } 14 | 15 | //default method 16 | public default void accept() { 17 | System.out.println("Mike finally accepted voice call.."); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day44_oopreview/callcenter/WhatApp2.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.callcenter; 2 | 3 | public class WhatApp2 implements VoiceCallable { 4 | 5 | public void call(String contact) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/day44_oopreview/callcenter/WhatsApp.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.callcenter; 2 | 3 | public class WhatsApp extends MessagingApp implements VoiceCallable,VideoCallable { 4 | 5 | @Override 6 | public void videoCall() { 7 | System.out.println("WhatsApp - doing a video call Mr mike..."); 8 | 9 | } 10 | 11 | @Override 12 | public void call(String contact) { 13 | System.out.println("WhatsApp - calling " + contact + "..."); 14 | 15 | } 16 | 17 | @Override 18 | public void sendMessage(String msg) { 19 | System.out.println("WhatsApp - sending a message - " + msg + "..."); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day44_oopreview/shapes/Diamond.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.shapes; 2 | 3 | public class Diamond extends Shape { 4 | 5 | public Diamond() { 6 | type="diamond"; 7 | } 8 | 9 | @Override 10 | public void draw() { 11 | System.out.println("Drawing a diamond"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/day44_oopreview/shapes/Shape.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.shapes; 2 | 3 | public class Shape { 4 | 5 | public String type; 6 | 7 | public Shape() { 8 | type="shape"; 9 | } 10 | 11 | public void draw() { 12 | System.out.println("Drawing a shape"); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/day44_oopreview/shapes/ShapeActions.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.shapes; 2 | 3 | import static day44_oopreview.shapes.ShapeManager.*; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class ShapeActions { 9 | 10 | public static void main(String[] args) { 11 | 12 | drawSquare((Square)buildShape("square")); 13 | 14 | drawShape(buildShape("shape")); 15 | 16 | System.out.println("-------------"); 17 | 18 | List myList = new ArrayList<>(); 19 | myList.add(new Shape()); 20 | myList.add(new Square()); 21 | myList.add(new Shape()); 22 | myList.add(new Square()); 23 | myList.add(new Diamond()); 24 | 25 | drawShape(myList); 26 | 27 | 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/day44_oopreview/shapes/ShapeTest.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.shapes; 2 | 3 | public class ShapeTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | //create 3 shapes, using polymorphis 8 | 9 | Shape square = new Square(); 10 | Shape diamond = new Diamond(); 11 | Object shapeObject = new Shape(); 12 | 13 | square.draw(); 14 | diamond.draw(); 15 | 16 | ((Square)square).squareMethod(); 17 | 18 | 19 | 20 | 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day44_oopreview/shapes/Square.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.shapes; 2 | 3 | public class Square extends Shape { 4 | 5 | public Square() { 6 | type="square"; 7 | } 8 | 9 | @Override 10 | public void draw() { 11 | System.out.println("Drawing a square"); 12 | } 13 | 14 | public void squareMethod() { 15 | System.out.println("Square method"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day44_oopreview/shapes/Triangle.java: -------------------------------------------------------------------------------- 1 | package day44_oopreview.shapes; 2 | 3 | public class Triangle extends Shape { 4 | 5 | public Triangle() { 6 | type = "triangle"; 7 | } 8 | 9 | @Override 10 | public void draw() { 11 | System.out.println("Drawing a triangle"); 12 | } 13 | 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day45_exceptionHandling/BadArray.java: -------------------------------------------------------------------------------- 1 | package day45_exceptionHandling; 2 | 3 | public class BadArray { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] number = {1,2,3}; 8 | 9 | for(int i=0;i<=number.length;i++) { 10 | System.out.println(number[i]); 11 | } 12 | 13 | System.out.println("Learning exception"); 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/day45_exceptionHandling/CheckedVSUncheckedException.java: -------------------------------------------------------------------------------- 1 | package day45_exceptionHandling; 2 | 3 | public class CheckedVSUncheckedException { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | try { 9 | Thread.sleep(2000); 10 | } catch (InterruptedException e) { 11 | // TODO Auto-generated catch block 12 | e.printStackTrace(); 13 | } 14 | 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day45_exceptionHandling/Nullpointer.java: -------------------------------------------------------------------------------- 1 | package day45_exceptionHandling; 2 | 3 | public class Nullpointer { 4 | 5 | static String name; 6 | 7 | public static void main(String[] args) { 8 | 9 | try { 10 | System.out.println(name.toUpperCase()); 11 | }catch(NullPointerException e) { //(Exception e) 12 | System.out.println("Nullpointerexception happened"); 13 | System.out.println("Here is the message: " + e.getMessage()); 14 | System.out.println("Here is the stack trace: "); 15 | e.printStackTrace(); 16 | 17 | 18 | } 19 | 20 | 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day45_exceptionHandling/OrCatchBlock.java: -------------------------------------------------------------------------------- 1 | package day45_exceptionHandling; 2 | 3 | public class OrCatchBlock { 4 | 5 | static String str; 6 | 7 | public static void main(String[] args) { 8 | 9 | try { 10 | 11 | System.out.println(str.toUpperCase()); 12 | 13 | }catch(IllegalArgumentException | NullPointerException e) { 14 | 15 | //Exception types can not be sub-parent types 16 | e.printStackTrace(); 17 | } 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day45_exceptionHandling/Runtimeerror.java: -------------------------------------------------------------------------------- 1 | package day45_exceptionHandling; 2 | 3 | public class Runtimeerror { 4 | 5 | public static void main(String[] args) { 6 | go(); 7 | } 8 | 9 | public static void go() { 10 | System.out.println("Going"); 11 | go(); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/day45_exceptionHandling/TryCatchFinally.java: -------------------------------------------------------------------------------- 1 | package day45_exceptionHandling; 2 | 3 | public class TryCatchFinally { 4 | 5 | public static void main(String[] args) { 6 | 7 | String str = "Selenium"; 8 | 9 | try { 10 | System.out.println(str.length()); 11 | System.out.println(str.charAt(100)); 12 | }catch(Exception e) { 13 | System.out.println("Enter correct index"); 14 | return; 15 | }finally { 16 | System.out.println("Finally block"); 17 | } 18 | 19 | System.out.println("Bye.."); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day45_exceptionHandling/TyCatch2.java: -------------------------------------------------------------------------------- 1 | package day45_exceptionHandling; 2 | 3 | public class TyCatch2 { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] nums = {36,6,34,12}; 8 | 9 | //System.out.println(nums[0]); //compile error 10 | 11 | try { 12 | System.out.println(nums[6]); 13 | }catch(Exception e) { 14 | //System.out.println("Wrong index"); 15 | //e.printStackTrace(); 16 | System.out.println(e.getMessage()); 17 | } 18 | 19 | try { 20 | int j=100; 21 | int n=j/0; 22 | }catch(ArithmeticException e) { 23 | e.printStackTrace(); 24 | System.out.println(e.getMessage()); 25 | } 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/day46_collection_part1/LinkedListExample.java: -------------------------------------------------------------------------------- 1 | package day46_collection_part1; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | public class LinkedListExample { 7 | 8 | public static void main(String[] args) { 9 | 10 | List list = new LinkedList<>(); 11 | list.add(10); 12 | list.add(50); 13 | list.add(500); 14 | list.add(50000); 15 | 16 | System.out.println(list.get(0)); 17 | System.out.println(list.get(1)); 18 | 19 | System.out.println(((LinkedList) list).getFirst()); 20 | 21 | ((LinkedList) list).addFirst(1); 22 | ((LinkedList) list).addLast(99); 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day46_collection_part1/VectorExample.java: -------------------------------------------------------------------------------- 1 | package day46_collection_part1; 2 | 3 | import java.util.List; 4 | import java.util.Vector; 5 | 6 | public class VectorExample { 7 | 8 | public static void main(String[] args) { 9 | 10 | List v = new Vector<>(); 11 | v.add("water"); 12 | v.add("tea"); 13 | v.add("green tea"); 14 | 15 | for(String str : v) { 16 | System.out.println(str); 17 | } 18 | 19 | System.out.println(v.size()); 20 | 21 | System.out.println(v.get(2)); 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day47_collection_part2/LoopSet.java: -------------------------------------------------------------------------------- 1 | package day47_collection_part2; 2 | 3 | import java.util.*; 4 | 5 | 6 | public class LoopSet { 7 | 8 | public static void main(String[] args) { 9 | 10 | Set numSet = new HashSet<>(); 11 | numSet.add(50); 12 | numSet.add(543); 13 | numSet.add(1150); 14 | numSet.add(550); 15 | numSet.add(570); 16 | numSet.add(93); 17 | numSet.add(5000); 18 | numSet.add(950); 19 | 20 | for(Integer n : numSet) { 21 | System.out.print(n + "|"); 22 | } 23 | 24 | System.out.println(); 25 | 26 | numSet.forEach(n -> System.out.print(n + "|")); 27 | 28 | 29 | 30 | 31 | 32 | } 33 | 34 | } 35 | --------------------------------------------------------------------------------