Ask Java Expert


Home >> Java

Write a program that converts US dollars into Canadian dollars, as shown in the following figure. The program let the user enter an amount in US dollars and display it equivalent value in Canadian dollars when clicking the Convert button. One dollar is 1.5 Canadian dollars. The layout should be designed following the draft layout shown in the second diagram.

479_Create a panel with BorderLayout.png

Question 5:

Answer the following questions by choosing the single most correct alternative from those given.
1. The method parses a string s to a double value.
a. double.parseDouble(s);
b. Double.parsedouble(s);
c. double.parseDouble(s);
d. Double.parseDouble(s);
2. What is the printout of the following code:
double x = 10.1;
int y = (int)x;
System.out.printIn("x is " + x + " and y is " + y):
a. x is10 and y is 10
b. x is 10.0 and y is 10.0
c. x is 11 and y is 11
d. x is 10.1 and y is 10
3. Which of the following is not a valid boolean expression.
a. (1 < x < 100);
b. (x = 1)11(x I= 1)
c. (x =< 5) & (x>=5)
d. The above are all wrong
4. Given the following method:
static void nPrint(String message, Int n) ( while (n > 0) {
System.out.print(message);
n-;
}
}
What is the printout of the call nPrint("a". 4)?
a. aaaaa
b. aaaa
c. aaa
d. invalid call
4. An array reference variable can be used in which of the following ways?
a. As a local variable
b. As a parameter of a method
c. Asa return value of a method
d. All of the above
5. Which of the following are valid array declarations
a. char(' charArray = new char(261:
b. Intl] words = new words[10];
c. chart] charArray = Computer Science";
d. double[3] nums = (3.5, 35.1, 32.0};
6. Suppose s1 and s2 are two strings. which of the following statements or expressions are Incorrect?
a. String s3 = 51 - s2;
b. int i = s1.compareTo(s2);
c. int j = s2.1ength():
d. char c = s1.charAt(stlength() - 1):
7. How can you Initialize a string with "123"?
a. String] string = {'l', '2', '3'};
b. String s = "123":
c. String s = new String("123");
d. both (a) and (c) are both fine, but (b) is better
8. Which method can be used to create an output object for file temp.td?
a. new Formatter('lemp.brt")
b. new Formatter(temp.bct)
c. new Formatter(new File("tempixt"))
new Formatter(File("tematd"))
9. When you implement a method that is defined in a superclass. you
a. Overload
b. Override
c. Copy
d. Call
10. The class is inherited by every Java class.
a. Class
b. Object
c. Number
d. Comparable
11. What method do you use to set the location of a frame on the screen?
a. setPosition
b. selLocation
c. setsize
d. setDimention the original method

12. What is the default layout manager for the content pane of a JFrame ?
a. FlowLayout
b. BorderLayout
c. GirdLayout cl. No default layout manager
13. What is the default layout manager for a JPanel?
a. FlowLayout
b. Borderlayout
c. GirdLayout
d. No default layout manager
14. draws a drcle whose center position is (400, 400) and whose radius is 50.
a. g.drawCircle(350, 350, 100, 100)
b. g.drawOval(350. 350, 100, 100)
c. g.drawCircle(400. 400. 50. 50)
d. g.drawOvale(400. 400. 50. 50)
15. What method do you use to set the text to the right of the icon in an instance jbt of JButton?
a. jbtsetHorizontalArignment(SwingContants.RIGHT)
b. bt.setVerticalAlignment(SwingContants.RIGHT)
c. btsetHorizontalTextPosItion(SwingContants.RIGHT)
d. btsetVerlicalTextPosition(SwingContants.RIGHT)
16. What method do you use to disable editing on an Instance jtf of JTextField?
a. jtt.setEditing(false)
b. jtt.setEditable(false)
c. ittenableEditing(false)
d. jltsetEcIlt (false)
17. Can a JComboBox instance generate the following events?
a. MouseEvent
b. ActionEvent
c. ItemEvent
d. All above
18. The method that executes immediately after the init() method in an applet is
a. destroy()
b. start()
c. stop()
d. run()
19. Which data structure is appropriate to store customers in a clinic for taking flu shots?
a. Stack
b. Queue
c. Priority Queue
d. Array List
20. Suppose List list = new ArrayList. Which of the following operations are correct?
a. list.add("Red");
b. list.add(new lnteger(100)):
c. list.add(new java.uULDate());
d. list.add(new ArrayList()):
21. To declare a class named A with two generic types. use
a. public class A
b. public class A
c. public class A(E) 1
d. public class A(E, F) }
22. Which of the data type below does not allow duplicates?
a. Set
b. List
c. Stack
d. LinkedList
23. Analyze the following code
import java.util.*: public class Test {
public static void main(String0 args) throws Exception (
Set set = new TreeSet();
setadd("Red"); setadd("Green"): set.add("Blue");
System.out.println(set.first());
}
}
a. The program displays Red
b. The program displays Blue
c. The program displays Green
d. The program may display Red, Blue, or Green.

24. which method do you use to test tt an element Is Ina set or list named tc?
a. (element instanceof [SOU (element instanceof Set)
b. xin(element)
c. x.contains(element) 0. x inctude(element)
25. Which method do you use to mid the number of elements In a set or list named r?
a. x.length()
b. x.count()
c. x.number()
0. x Size()
26. WhIch method do you use to remove an element from a set or list named x? a. x.delete(eleMent)
D. xremove(element)
c. x deletes(element)
d. x remOves(element)
27. wntr_n of the following is correct to sort the elements In a list Ist? a. 1St sort()
D. C011eCtiOnS.SOrt(ISt)
c. Arrays.sort(Ist)
d. new linkedList(new StrIngrred". 'green". "blue"))
29. Which method on a condition should you Invoke to causes the current thread to wait until the condition Is signalled?
a. ConditiOn.vraiteda
b. COnditiOn.awarta
c. comlnion.waitinga
0. COnditiOn.waita
30 Suppose that your program accesses MySOL or Oracle database. Which c4 to follovang staterneMs are true?
a. d the driver for MySOL and Oracle are not in the classpath, the program M have a runbme error. indicating that the driver Naas cannot be loaded
b. the database is not available. the program will have a runtime error. when attempting to create a Connection object.
C. If the database is not available. the program will have a syntax error.
d if the driver for MySOL and Oracle are not in the dasspar, the program ws have a syntax error
30. Analyze the following code.
ResubSel resullSet statement execuleOuery
(select arStName. ml, lastName from Student where laniMme" + " = 'smith");
System.out println(resullSet gelStrIng(1)).
Minch Of to toarmIng are right? (multiple Answers)
a if the SOL SELECT statemeM returns no result resubSet is null
b. resultSel getStnng(1) returns the erstName field in the mesa set
c mune! getStmg(1) returns the nv field in the result set
d The program MI have a runtime error. because the cursor in resultSet does not point to a row. You must use resubSet next() to move the cursor to the ersi row in the result set Subsequently. restaiSet mead() moves the cursor to the neat row in the result set

31 in a relational data model. provides the means for accessirg and manrthating data

a SOL
a Executor
C Structure
m Integrity
32 whim of the folloMng statements are true? (Muni* Afts*Cfs)
a You may load multiple ADC drivers xi a program
0. You may create multiple connections to a database.
C You Can send buena and update statements through a Statement object
m YOU may 33 TO execute a SELECT statement 'SOW • from Address' on a Statement oiled stmt. use a stmt execulerselect • from Andress"),
b. at m duery("Select * from Andreas").
C SIN execuleOumy(seled * from Address").
d situ execuleUmlaterseled * frC01 Addf CSC).
14 lAtuch of the lodging statements is not true?
a. A panel can be placed inside a panel.
b. A frame can be placed inside a frame.
c. A source object and a listener °bled can be the same.
d. A source object can register many listeners.
35. Mat should you use to positon a button with.. an application frame so that the size of the button is NOT affedeci by the frame size? a. a FlOvelayOut
b a GndlayOut
c. the center area of a BorderLayout
0 the East or Weal area of a BorderlayOut
e the North or South area of a BorderLayotil
36 F at wo the code in Comparable c = new Data();
a.
b <1>
C
d.
37. Analyze the following code
import java.utr;
public class Test (
public static void main (String II args) throws Exception
TreeSet set = new TreeSet();
set set.add("Yelow"); set.add("Green"); set.add("Blue"); SortedSet temp = set.headSet("Purple");
System.oul.println(temptirst());
a. The program displays Blue
b. The program displays Red
c. The program displays Green
d. The program displays Yellow
e. The program displays Purple
38. Which of the following is correct to create a list from an array?
a. new List(("red", "green', "blue"))
b. new List(new Stringrred", "green", "blue"))
c. Arrays.asList(new Stringrred", "green", "blue"))
d. new ArrayList(new Stringu("red", "green", "blue"))
e. new LinkedList(new Stringrred", "green", "blue"))
39. Much layout manager would you use to place three GUI components in a frame so that all components have the same sae?
a. GndLayout
b. F lowLayoul
C. 8orderLayout
d. CardLayout

Java, Programming

  • Category:- Java
  • Reference No.:- M91031710

Have any Question?


Related Questions in Java

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 taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

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 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 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