Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Multiple Choice and T/F Questions-

1. What is the output of the following statements? _______________

int x = 10;
x++;
int y = 11;
System.out.println(x);

A. 10
B. 11
C. y
D.x

2. 5 % 4 is _____

A. 0
B. 3
C. 4
D. 1

3. The equal comparison operator in Java is __________.

A. !==
B. ^=
C. <>
D. !=

4. To add a to b and store result in a, you write (Note: Java is case-sensitive)

A. b = A + b;
B. b += a;
C. a += b;
D. a = B + a;

5. Which of the following should be declared as a void method?

A. Write a method that converts an uppercase letter to lowercase.
B. Write a method that returns a random integer from 1 to 100.
C. Write a method that prints integers from 0 to 10.
D. Write a method that checks whether current second is an integer from 1 to 60.

6. Android apps are developed with Java.

True/False

7. Microsoft Visual Studio is the recommended integrated development environment for Android development, though developers may also use a text editor and command-line tools to create Android apps.

True/False

8. Layout files are stored in the project's res/menu folder.

True/False

9. A LinearLayout always arranges GUI components horizontally.

True/False

10. Android development is a combination of GUI design, Java, and XML coding.

True/False

Short Answer Questions-

11. Assume x is 80. What is the output of the following statement? Briefly explain your answer.

if (x >= 80){
System.out.print("A");
}
else if (x >=60){
System.out.print("B");
}
else{
System.out.print("C");
}

12. Write a program that prompts the user to enter an integer. If the number is a multiple of 3, print "Multiple of 3."Otherwise, print "Not Multiple of 3." Here are the sample runs:


Enter an integer: 6
Multiple of 3


Enter an integer: 10
Not Multiple of 3

13. What is the output for y?Briefly explain your answer.

int y = 0;
for (int i = 2; i <4; i++) {
y += i;
}
System.out.println(y);

14. What is the output of running the class C. Briefly explain your answer.

class A {
public String toString() {
return "AA";
}
}

class B extends A {
public String toString() {
return "BB";
}
}

public class C extends B{
public static void main(String[] args) {

A a = new A();
Bb = new B();
C c = new C();
System.out.println(a.toString()); // toString "A"
System.out.println(b.toString()); // toString "B"
System.out.println(c.toString()); // toString "B"
}
}

15. Change the following whilestatement using thefor statement.

int x = 1;
while (x <5){
System.out.println(x);
x++;
}

16. Complete the code:

public class Test {
public static void main(String[] args) {
int i = 4; int j = 5;

// Fill in the code to invoke the printAverage method to display the average of i and j.

}

public static void printAverage(int i, int j) {
// Fill in the code here to display the average of i and j.

}

}

17. How many times x will be printed? Briefly explain your answer.

int x = 1;
while (x <10){
System.out.println(x);
x++;
}

18. Create setter and getter for each member variable in the following class:

public class Stock {
private String stockName;
private double currentPrice;

// create a setter for "stockName"

// create a getter for "stockName"

// create a setter for "currentPrice"

// create a getter for "currentPrice"

}

19. Assume that you have the following xml file in your res/layout folder and the name of the xml file is activity_main.xml:

119_Code.png

(a) In order to display this user interface, what method call in Java will you use and how would you write that entire method call?

(b) How would the above layout xml file display on the screen?

20. Short Answer Questions (10 points)

(a) Suppose that "car_small.png" file is located in res/drawable folder.

- How can you refer to this file in Java code?

- How can you refer to this file in the layout XML file?

Java, Programming

  • Category:- Java
  • Reference No.:- M91518856
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Java

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As