Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Let variable = [1, [2], [[3]],[[[4]]]]


Output should be: [1, 2, 3, 4]


Dont use flatten function.


Use for loop

Create 3 arrays that will hold 5 employee information:



Name



Address



Email



For example: empName[0], empAddress[0], empEmail[0] should belong to the same employee.



We will output the employee's information by using int variable as index.



The user will select what index will be printed on the console so you need to use the java.util.scanner.

Using inheritance, one class can acquire the properties of others. Consider the  following Animal class: 

class Animal{ 

 void walk(){ 

 System.out.println("I am walking"); 

 } 

This class has only one method, walk. Next, we want to create a Bird class that also  has a fly method. We do this using extends keyword: 

class Bird extends Animal { 

 void fly() { 

 System.out.println("I am flying"); 

 } 

Finally, we can create a Bird object that can both fly and walk

public class Solution{ 

 public static void main(String[] args){ 


 Bird bird = new Bird(); 

 bird.walk(); 

 bird.fly(); 

 } 

The above code will print: 

I am walking 

I am flying 

This means that a Bird object has all the properties that an Animal object has, as well  as some additional unique properties. 

The code above is provided for you in your editor. You must add a sing method to  the Bird class, then modify the main method accordingly so that the code prints the  following lines: 

I am walking 

I am flying

I am singing


Write a Java method to check whether a string is a valid password.

Password rules:

A password must have at least ten characters.

A password consists of only letters and digits.

A password must contain at least two digits.

Expected Output:

1. A password must have at least ten characters.

2. A password consists of only letters and digits.

3. A password must contain at least two digits

Input a password (You are agreeing to the above Terms and Conditions.): abcd1234

Password is valid: abcd1234


We want make a package of goal kilos of chocolate. We have small bars (1 kilo

each) and big bars (5 kilos each). Return the number of small bars to use, assuming

we always use big bars before small bars. Return -1 if it can't be done.


makeChocolate(4, 1, 9) → 4

makeChocolate(4, 1, 10) → -1

makeChocolate(4, 1, 7) → 2

Skeleton of the method you should use to return the number:

public int makeChocolate(int small, int big, int goal) {

}


Create a class named Vehicle with instance variables make (String type), color (String type), year ( integer type) and model ( String type). All the variables have default access behaviour.  Vehicle class also contains a constructor with four parameters to initialize the make, color, year and model of a specific Vehicle object.

Vehicle class also has a method named printDetails() with return type void and default access to show the output of make, color, year and model of a specific Vehicle object. 

Create another class named Car that inherits Vehicle class. Car class has a private instance variable called bodyStyle (String type). The Car class also should have a constructor with five parameters. Now create the main class named Main. Inside the main method of the Main class create an object of Car class by calling the Car class constructor. Then call the printDetails() method using the created object. Finally also output body style of the Car object.


How do you call an instance variable in the main program?


Write a program that prompts the user to input an integer



between 0 to 35. It the number is less than or equal to 9, the



program should output the number; otherwise, it should output



A for 10, B for 11, C for 12, …, and Z for 35. (hint: use the cast



operator, (char)(), for numbers >+ 10.

Create 3 arrays that will hold 5 employee information:


Name


Address


Email


For example: empName[0], empAddress[0], empEmail[0] should belong to the same employee.


-----------------------------------------------------------------------------------------------------------------------------------------------------


We will output the employee's information by using int variable as index.


The user will select what index will be printed on the console so you need to use the java.util.scanner.

Create 3 arrays that will hold 5 employee information:


Name


Address


Email


For example: empName[0], empAddress[0], empEmail[0] should belong to the same employee.


-----------------------------------------------------------------------------------------------------------------------------------------------------


We will output the employee's information by using int variable as index.


The user will select what index will be printed on the console so you need to use the java.util.scanner.

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS