CIS355A Week 4 Quiz – Guaranteed 100% score

Lab Price = $10
Please feel free to send us your queries at: support@iqrajavaid.com
Payment Methods

Add to Cart

Buy Now

View Cart


Problem Statement
CIS355A Week 4 Quiz

1. (TCOs 1–8) Which of the following is a correct interface? (Points : 3)
abstract interface A { abstract void print({ };}
interface A { void print() { }; }
abstract interface A { print(); }
interface A { void print();}

Question 2.2. (TCOs 1–8) Analyze the following code.
import java.util.*; // 1
public class Test { // 2
public static void main(String[ ] args) { // 3
Calendar[ ] calendars = new Calendar[10]; // 4
calendars[0] = new Calendar(); // 5
calendars[1] = new GregorianCalendar(); // 6
} // 7
} // 8 (Points : 3)
The program has a compile error on Line 4 because java.util.Calendar is an abstract class.
The program has no compile errors.
The program has a compile error on Line 6 because Calendar[1] is not of a GregorianCalendar type.
The program has a compile error on Line 5 because java.util.Calendar is an abstract class.

Question 3.3. (TCOs 1–8) What is the output of Integer.parseInt(“10”, 2)? (Points : 3)
Invalid statement;
2;
1;
10;

Question 4.4. (TCOs 1–8) Analyze the following code.
Number numberRef = new Integer(0);
Double doubleRef = (Double)numberRef; (Points : 3)
The compiler detects that numberRef is not an instance of Double.
The program runs fine, since Integer is a subclass of Double.
A runtime class casting exception occurs, since numberRef is not an instance of Double.
You can convert an int to double, so you can cast an Integer instance to a Double instance.
There is no such class named Integer. You should use the class Int.

Question 5.5. (TCOs 1–8) To divide BigDecimal b1 by b2, and assign the result to b1, you write _____ (Points : 3)
b1 = b1.divide(b2);.
b1 = b2.divide(b1);.
b1 = b2.divide(b1);.
b1.divide(b2);.
b2.divide(b1);.

Question 6.6. (TCOs 1–8) Analyze the following code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame {
public void Test() {
JButton jbtOK = new JButton(“OK”);
add(jbtOK);
jbtOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println(“The OK button is clicked”);
}
});
}
public static void main(String[ ] args) {
JFrame frame = new Test();
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
} (Points : 3)
The actionPerformed method is not executed when you click the OK button, because no instance of Test is registered with jbtOK.
When you run the program, the button is not displayed, because the constructor is declared wrong. It should be declared public Test(), not public void Test().
The message, “The OK button is clicked,” is displayed when you click the OK button.
The program has a compile error because no listeners are registered with jbtOK.
The program has a runtime error because no listeners are registered with jbtOK.

Question 7.7. (TCOs 1–8) To listen to mouse-clicked events, the listener must implement the _____ interface or extend the _____ adapter. (Points : 3)
MouseMotionListener/MouseMotionAdapter
WindowListener/WindowAdapter
ComponentListener/ComponentAdapter
MouseListener/MouseAdapter

Question 8.8. (TCOs 1–8) Clicking the closing button on the upper-right corner of a frame generates a(n) _____ event. (Points : 3)
ContainerEvent
WindowEvent
MouseMotionEvent
ItemEvent
ComponentEvent

Question 9.9. (TCOs 1–8) Which statement is true about a non-static inner class? (Points : 3)
It must implement an interface.
It must be final if it is declared in a method scope.
It is accessible from any other class.
It can access private instance variables in the enclosing object.
It can only be instantiated in the enclosing class.

Question 10.10. (TCOs 1–8) The method in the ActionEvent _____ returns the action command of the button. (Points : 3)
getActionCommand()
getModifiers()
getID()
paramString()

Question 1.1. (TCOs 1–8) Which of the following statements are false? (Points : 3)
If you compile an interface without errors, but with warnings, a .class file is created for the interface.
If you compile an interface without errors, a .class file is created for the interface.
If you compile a class with errors, a .class file is created for the class.
If you compile a class without errors but with warnings, a .class file is created.

Question 2.2. (TCOs 1–8) To divide BigDecimal b1 by b2, and assign the result to b1, you write _____ (Points : 3)
b1 = b1.divide(b2);.
b1 = b2.divide(b1);.
b1 = b2.divide(b1);.
b1.divide(b2);.
b2.divide(b1);.

Question 3.3. (TCOs 1–8) In JDK 1.5, you may directly assign a primitive data type value to a wrapper object. This is called _____ (Points : 3)
auto boxing.
auto unboxing.
auto casting.
auto conversion.

Question 4.4. (TCOs 1–8) Assume Calendar calendar = new GregorianCalendar(). _____ returns the month of the year. (Points : 3)
calendar.get(Calendar.MONTH)
calendar.get(Calendar.WEEK_OF_MONTH)
calendar.get(Calendar.MONTH_OF_YEAR)
calendar.get(Calendar.WEEK_OF_YEAR)

Question 5.5. (TCOs 1–8) What is the output of the following code?
public class Test {
public static void main(String[ ] args) {
java.math.BigInteger x = new java.math.BigInteger(“3”);
java.math.BigInteger y = new java.math.BigInteger(“7”);
x.add(y);
System.out.println(x);
}
} (Points : 3)
3
11
10
4

Question 6.6. (TCOs 1–8) The interface _____ should be implemented to listen for a button action event. (Points : 3)
FocusListener
ContainerListener
ActionListener
MouseListener
WindowListener

Question 7.7. (TCOs 1–8) Which of the following is not a correct name for listener adapters? (Points : 3)
MouseAdapter
ActionAdapter
KeyAdapter
WindowAdapter

Question 8.8. (TCOs 1–8) Analyze the following code.
import java.awt.*; // 1
import java.awt.event.*; // 2
import javax.swing.*; // 3
// 4
public class Test extends JFrame { // 5
public Test() { // 6
JButton jbtOK = new JButton(“OK”); // 7
JButton jbtCancel = new JButton(“Cancel”); // 8
getContentPane().add(jbtOK); // 9
getContentPane().add(jbtCancel); // 10
jbtOK.addActionListener(this); // 11
jbtCancel.addActionListener(this); // 12
} // 13
// 14
public void actionperformed(ActionEvent e) { // 15
System.out.println(“A button is clicked”); // 16
} // 17
// 18
public static void main(String[ ] args) { // 19
JFrame frame = new Test(); // 20
frame.setSize(300, 300); // 21
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 22
frame.setVisible(true); // 23
} // 24
} // 25 (Points : 3)
The program has runtime errors on Lines 9 and 10 because jbtOK and jbtCancel are added to the same location in the container.
The program has compile errors on Line 15 because the signature of actionperformed is wrong.
The program has compile errors on Line 20 because new Test() is assigned to frame (a variable of JFrame).
The program has compile errors on Lines 11 and 12 because Test does not implement ActionListener.

Question 9.9. (TCOs 1–8) Pressing a button generates a(n) _____ event. (Points : 3)
ContainerEvent
MouseMotionEvent
ItemEvent
ActionEvent
MouseEvent

Question 10.10. (TCOs 1–8) The method in the ActionEvent _____ returns the action command of the button. (Points : 3)
getActionCommand()
getModifiers()
getID()
paramString()

Screenshots
Instructions
* If you want to purchase multiple products then click on “Buy Now” button which will give you ADD TO CART option.Please note that the payment is done through PayPal.
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at support@iqrajavaid.com.
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at support@iqrajavaid.com and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at support@iqrajavaid.com.
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Payment Details

 

Lab Price = $10
Please feel free to send us your queries at: support@iqrajavaid.com
Payment Methods

Add to Cart

Buy Now

View Cart

Privacy Policy
We take your privacy seriously and will take all measures to protect your personal information.
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
Refund Policy
Incase you face any issues with the tutorial, please free to contact us on support@iqrajavaid.com
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.


Leave a Reply