Techsparx Java Tuitions
Total Page:16
File Type:pdf, Size:1020Kb
TechSparxJavaTuitionsTechSparxJavaJava Question Bank TuitionsTechSparxJavaTuitionsTechSp arxJavaTuitionsTechSparxJavaTuitions TechSparxJavaTuitionsTechSparxJavaTechSparx Java Tuitions “Better than a thousand days of diligent study is one day with a Great Teacher” TuitionsTechSparxJavaTuitionsTechSp Java Question Bank (version 5.3) arxJavaTuitionsTechSparxJavaTuitionshttp://techsparx.webs.com/ Saravanan.G TechSparxJavaTuitionsTechSparxJava TuitionsTech SparxJavaTuitionsTechSp arxJavaTuitionsTechSparxJavaTuitions TechSparxJavaTuitionsTechSparxJava TuitionsTechSparxJavaTuitionsTechSp arxJavaTuitionsTechSparxJavaTuitions TechSparxJavaTuitionsTechSparxJava TuitionsTechSparxJavaTuitionsTechSp arxJavaTuitionsTechSparxJavaTuitions TechSparxJavaTuitionsTechSparxJava TuitionsTechSparxJavaTuitionsTechSp Contents Modularization ........................................................................................................................................ 3 Most Simplest ......................................................................................................................................... 4 Decision Making Statements ................................................................................................................... 5 Switch Statement .................................................................................................................................... 6 Looping Constructs .................................................................................................................................. 7 Numbers ................................................................................................................................................. 8 Series .................................................................................................................................................... 11 Patterns ................................................................................................................................................ 12 Strings ................................................................................................................................................... 14 One Dimensional Array .......................................................................................................................... 18 Searching and Sorting ............................................................................................................................ 19 Strings and Arrays.................................................................................................................................. 20 Classes, Objects, Functions and Constructors......................................................................................... 21 Two Dimensional Array.......................................................................................................................... 23 Output Programs ................................................................................................................................... 24 2 TechSparx Java Tuitions - 9880 205065 Modularization Module 1 Java basics Module 2 Most Simplest Module 3 Decision Making Statements Module 4 Switch Statement Looping Constructs Module 5 Numbers Module 6 Series Module 7 Patterns Module 8 Strings Module 9 One Dimensional Array Module 10 Searching and Sorting Module 11 Strings and Arrays Classes, Objects, Functions and Module 12 Constructors Module 13 Exception Handling Module 14 Encapsulation(Access Specifier) Module 15 Scanner class Module 16 Two Dimensional Array Module 17 Output Programs Theoretical -BufferedReader Module 18 -Input and Output Stream -Wrapper class -Math class 3 TechSparx Java Tuitions - 9880 205065 Most Simplest 1. Write a program (WAP) to print “Hello World”. 2. WAP to print your name. 3. WAP to add two numbers and display the given numbers and the sum. 4. WAP to find the difference of two numbers and display the given numbers and the difference. 5. WAP to find the product of two numbers and display the given numbers and the product. 6. WAP to find the quotient of two numbers and display the given numbers and the quotient. 7. WAP to find the remainder of two numbers and display the given numbers and the remainder. 8. WAP to find the sum, difference, product, quotient and remainder of two numbers. 9. WAP to find area of a square. 10. WAP to find area of a rectangle. 11. WAP to find area of a triangle whose sides are given. 12. WAP to find the area of a circle. 13. WAP to convert Fahrenheit to Celsius 14. WAP to convert Celsius to Fahrenheit. 15. WAP to calculate the simple interest. 16. WAP to calculate the compound interest. Important formulas: 1. Fahrenheit = (Celsius * 1.8) + 32 2. Area of square = side * side 3. Area of Rectangle = length * breadth 4. Area of a circle = π * r * r 5. Area of a triangle = √(s(s-a)(s-b)(s-c)) where s = (a + b + c)/3 6. Roots of quadratic equation X = (-b ± √(b2 – 4ac)) / (2a) 7. Simple Interest = (principal * rate * time) / 100 8. Compound Interest = principal * ( (1 + (rate/100))time - 1) 4 TechSparx Java Tuitions - 9880 205065 Decision Making Statements 1. Write a program to find the largest of two given numbers. 2. Write a program to find the smallest of two given numbers. 3. Write a program to find if the given number is an ODD number. 4. Write a program to find if the given number is an ODD or EVEN number. 5. Write a program to find if the given number is DIVISIBLE by 7(seven). 6. Write a program to find the largest of three given numbers. 7. Write a program to find the smallest of three given numbers. 8. Write a program to find the real roots of a quadratic equation. (ax2 + bx + c = 0) 9. Write a program to print the grade based on the marks obtained according to the following table Marks Grade >=80 A 60 to 79 B 50 to 59 C 40 to 49 D <40 E 10. Write a program to print the day of week. (using else if ladder) Example: day = 1 dayOfWeek = “Monday” day = 2 dayOfWeek = “Tuesday” 11. Write a program to print the month of the year. (using else if ladder) Example: month = 1 --> monthOfYear = "January" month = 2 --> monthOfYear = "February" 12. Write a program to check if the given character is a digit or upper case letter or a lower case letter or a special character. 13. Write a program to check if the given character is a vowel. 14. Write a program to check if the given number is a buzz number. (Buzz number: A number which is either divisible by 7 or ends with 7. For Example: 67, 49, 37, 21 etc 5 TechSparx Java Tuitions - 9880 205065 Switch Statement 1. Write a program to input number of week’s day (1-7) and translate to its equivalent name of the day of the week. (Example: 1 to Sunday, 2 to Monday… 7 to Saturday) 2. Write a program to input number of month of the year (1 - 12) and translate to its equivalent name of the month. (Example: 1 to January, 2 to February … 12 to December) 3. Write a program to check if the given character is a vowel. 4. Using a switch statement, write a MENU driven program to find the sum, difference, product quotient and remainder. OR Write a program to simulate a SIMPLE CALCULATOR. 5. Using a switch statement, write a MENU driven program to convert a given temperature from Fahrenheit to Celsius and vice versa. For an incorrect choice, an appropriate error message should be displayed. 6. Using a switch statement, write a MENU driven program to calculate the AREA of square, rectangle, triangle and circle. 6 TechSparx Java Tuitions - 9880 205065 Looping Constructs 1. Write a program to print 5 stars. 2. Write a program to print n natural numbers. 3. Write a program to print all even numbers from 50 to 500 (inclusive of 50 and 500) 7 TechSparx Java Tuitions - 9880 205065 Numbers For Loop 1. Write a program to a. Calculate the nth repunit b. Calculate and display first n repunits. 2. WAP a. Calculate nth mersenne number. b. Calculate and display first n Mersenne number (binary repunits). 3. Write a program to display the divisors/factors of a given number. 4. Write a program to calculate the sum of factors of a given number. 5. Write a program to check if two given numbers are amicable. 6. Write a program to find the a. Factorial of n. b. Double Factorial of n. c. Triple Factorial of n. 7. Write a program to check if the given number is a Perfect square. 8. Write a program to find if the given number is one of the following: a. Perfect Number b. Deficient Number c. Abundant Number 9. Write a program to check if the given number is a Prime Number. 10. Write a program to display all the prime numbers from 1 to n. 11. Write a program to display first 20 prime numbers. 12. Write a program to find the Primorial of the given number. While Loop 13. Write a program to check if the given number is a palindrome. 14. Write a program to check if the given number is an Armstrong/Narcissistic Number. 15. Write a program to convert a binary number to decimal number. 16. Write a program to convert a Decimal Number to Binary. 17. Write a program that accepts a number and checks whether it is an AUTOMORPHIC Number. 18. Write a program to calculate the LCM and HCF/GCD of two given numbers. 19. Write a program to check if the given number is a SPECIAL number. 20. Write a program to print first 10 buzz numbers. 21. Write a program to check if the given number is a MAGIC Number 8 TechSparx Java Tuitions - 9880 205065 Definitions of different kinds of numbers: 1. Armstrong or Narcissistic Number: When the sum of the cubes of each digit in the number is equal to the number itself then