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

Question 2. Choose one answer of the following multiple choice questions:
1-What is displayed by: System.out.println("1" + 2 + 3);
a) 6
b) 15
c) 123
d) a syntax error

2-What is the number of loops in the following for statement?
for( int i = 0; i < n; i++ ) { // statement; }
a) Infinite loop
b) n
c) n - 1
d) n + 1

3-What is the returnValueType of the following method?
public static _____________ myMmethod(byte x, double y) {
return (long)x / y * 2; }
a) int
b) byte
c) long
d) double

4-Which two are acceptable data types for x?
switch( x ) {
default: System.out.println("Hello");
}
a) byte and char
b) long and short
c) char and double
d) float and int

5-What is the value of str2 after the following statements are executed?
String str1, str2, str3 = "Today is Wednesday.";
str1 = str3.substring(9, 18);
str2 = str1.substring(0, 3);
a) Tod
b) Wed
c) Wedn
d) Is
Question 1. Write True or False for each of the following statements.(corecct if fales)
1-If a method does not return a value, the return value type must be static.
2-The expression !(true || true && false || !true) is evaluated to true.
3-Every array has a length that specifies the number of elements in the array.
4-It is possible for the body of a do-while statement to never be executed.
5-The statement import java.*.*; is valid if placed at the very top of a Java source file.
6-The expression s.indexOf(",") returns the position of a comma in s, a String object.
7-The following statement System.out.print("Hi".compareTo("Hi") == 0); is correct.
8-The switch selection structure must end with the default case.
9-Variables declared in the body of a particular method are known as local variables.
10-int array = new int[10]; creates an integer array of size 10
Question 1. Write True or False for each of the following statements.(corecct if fales)
1-If a method does not return a value, the return value type must be static.
2-The expression !(true || true && false || !true) is evaluated to true.
3-Every array has a length that specifies the number of elements in the array.
4-It is possible for the body of a do-while statement to never be executed.
5-The statement import java.*.*; is valid if placed at the very top of a Java source file.
6-The expression s.indexOf(",") returns the position of a comma in s, a String object.
7-The following statement System.out.print("Hi".compareTo("Hi") == 0); is correct.
8-The switch selection structure must end with the default case.
9-Variables declared in the body of a particular method are known as local variables.
10-int array = new int[10]; creates an integer array of size 10
Write the method playGame, which simulates a game between player 1 and player 2based on the rules and example shown at the beginning of the question. Both player 1 and player 2 start the game with startingCoins coins. Computer player 1 spends 1,23 coins based on the value returned by the method getPlayer (. Computer player 2 spends 1, 2, or 3 coins based on the value returned by the method getPlayer2Move (. The game ends when maxRounds rounds have been played or when a player's coin count is less than 3 at the end of a round. At the end of the game, the winner is determined according to the following rules.
Write a program that asks the user for an input string. The program produces a table showing each character and the Unicode/ASCII value for that character.
A school has three houses A, B and C. Write a program to read a house and the points awarded for winning each race in an athletic finals terminated by ā€œDā€. Calculate and print the total points gained by each house appropriately labeled. Also print the 1 St and 3rd house entered and the points.
Program 1 - Vehicle load capacity
Every vehicle has a maximum value, in kilograms, that can be loaded unto the vehicle.
You must write a small application in JAVA that can assist a builder to determine if the goods he wants to buy weighs less than load capacity of his truck.
Your program must:-
1. Read the load capacity of the vehicle as input
2. Read the name and weight of three items as input
3. Calculate the total weight for the items
4. Display all items and the weight.
5. Display the total weight for all items
6. If the total weight of the items is less than the load capacity of the vehicle, display the
available weight capacity of the truck
7. If the total weight of the items is greater than the load capacity of the vehicle, display the
value that is more than the load capacity of the vehicle.
Remember that all output must be user-friendly.
draw a trapezoid
write a program to draw a dog house use fillRect for the use, drawLine for the roof (you cant fill it though), fillRect for the door, drawString to print your dogs name over the door
write a program to create a picture frame. use fillRect() to create the bottom layer in one color. use another fillRect for an inner rectangle for the next layer in another color. finally use fillOval() inside the inner rectangle for the top layer in a 3rd color
LATEST TUTORIALS
APPROVED BY CLIENTS