Input (Char Array) | Output (Two Dimensional Char Array) |
---|---|
{M, Y} | {{M, Y}, |
{B, A, T} | {{A, B, T}, |
{M, O, N} | {{M, N, O}, |
{J, U, B, A} | {{A, B, J, U}, |
class GetAllCharCombinations
{ public static void main(String s[])
{
char input[] = {'B', 'A', 'T'};
char[][] words = getAllCombinations(input);
for (char[] word : words) {
for (char letter : word) {
System.out.print(letter);
}
System.out.println();
}
}
public static char[][] getAllCombinations(char word[]) {
//Write code here to get all the combinations of the given word.
}
//If required write any additional methods here
}
class BikeTester
{
public static void main(String s[])
{
Bike bike;
bike.company = "Hero Honda";
bike.model = "Shine";
bike.cc = 125;
bike.mileage = 72.5;
bike.diskBrakes = false;
System.out.println(bike.company + "'s " + bike.model + " gives a mileage of " + bike.mileage + "kmpl.");
}
}
class Bike
{
String company;
String model;
int cc;
double mileage;
boolean diskBrakes;
}
A. | Hero Honda's Shine gives a mileage of 72.5kmpl. |
B. | Compilation error - since Bike class has two Strings - company and model. |
C. | Runtime Error - NullPointerException since the bike object is not created. |
D. | Compilation error - since Bike class does not have a constructor. |