Java Assignment

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Java Coding Questions

1. Check if two given string is Anagram of each other

2. Print all permutations of a given String. For example, if given String is "GOD" then your program
should print all 6 permutations of this string e.g. "GOD", "OGD", "DOG", "GDO", "ODG", and
"DGO"

3. Given two sorted arrays, merge them such that the elements are not repeated

Array 1: 2,4,5,6,7,9,10,13 Array 2: 2,3,4,5,6,7,8,9,11,15

Merged array: 2,3,4,5,6,7,8,9,10,11,13,15

4. Write a program to give the following output for the given input

Input: b3c6d2 Output: bbbccccccdd

5. Given a string, return the "reversed" string where all characters that are not a letter stay in the
same place, and all letters reverse their positions.
Example1: Input: "ab-cd" Output: "dc-ba"
Example2: Input: " Test1ng-Leet=code-Q!" Output: " Qedo1ct-eeLg=ntse-T!"

6. Given a paragraph and a list of banned words, return the most frequent word that is not in the
list of banned words.
Input: = "Bob hit a ball, the hit BALL flew far after it was hit."
banned = ["hit"]
Output: "ball"

7. Given an array length 3 or more of ints, return the difference between the largest and smallest
values in the array.

8. Given an array of strings, return a Map<String, Integer> with a key for each different string, with
the value the number of times that string appears in the array.
Input : ["a", "b", "a", "c", "b"] Output: {"a": 2, "b": 2, "c": 1}

9. Write a Java program to convert a string to date (showing date, month, year, time(hours,
minute, secs) with time zone)

10. Write a Java program explain static and dynamic polymorphism

You might also like