Key Quiz 3
Key Quiz 3
Key Quiz 3
Quiz 3 [IT112]
.............................................................................................................................................
.............................................................................................................................................
p.35-36
.............................................................................................................................................
.............................................................................................................................................
Q 2. Multiple Choice Questions (13 points) .Each question has EXACTLY one correct answer.
4 - Which is a technique in Java in which a class can have any number of constructors
that differ in parameter lists?
A- Constructor overloading
B- Method overloading
C- Operator overloading
D- None of the above
Page 2 of 7 1/12/2017 1:17 PM
return
10-Which of the following is NOT a valid Data data type?
type?
A. void
Page 3 of 7 1/12/2017 1:17 PM
B. int
C. String
D. static
A. 14523 500
B. 500
C. 500 500
D. 14523 500 500
E. 14523 500 Number balance
F. 14523 Number 500 balance
Page 4 of 7 1/12/2017 1:17 PM
Product.java
public class Product {
private int productId;
private String productName;
private String productDescription;
private double price;
public Product(int Id, String Name, String description, double Price)
{
productId = Id;
productName = Name;
productDescription = Description;
price = Price;
}
public int getProductId(){return productId;}
public void setProductId(int product){productId = product;}
public String getProductName(){return productName; }
public void setProductName(String Name){productName =Name;}
public String getProductDescription(){return productDescription; }
public void setProductDescription(String Des){
productDescription = Des; }
public double getPrice() { return price; }
public void setPrice(double Price) {price = Price; }
ProductMain.java
import java.io.Scanner;
public class ProductMain {
public static void main() {
System.out.println("Product 2"+p2.toString());
System.out.println("Product 3"+p3.toString());
System.out.println("Product 4"+p4.toString());
break;
case 2 :
String Description=sc.next();
if(p1.getProductDescription()== Description)
System.out.println("Found Product is:"+p1.toString());
else if(p2.getProductDescription()== Description)
System.out.println("Found Product is:"+p2.toString());
else if(p3.getProductDescription()== Description)
System.out.println("Found Product is:"+p3.toString());
else if(p4.getProductDescription()== Description)
System.out.println("Found Product is:"+p4.toString());
else System.out.println(Description +"Not Found !");
break;
case 3 :
double max=p1.getPrice();
if(p2.getPrice()>max) max=p2.getPrice;
else if(p3.getPrice()>max) max=p3.getPrice;
else if44(p4.getPrice()>max) max=p4.getPrice;
System.out.println("The max price of product is :"+max);
break;
Ch=3
……………………………………………………………………………………………………………………………………………………
The max price of product is :5000.00
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
ch=2 Description =”Laptop”
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
Found Product is:price=4000.00 productDescription=Laptop
……………………………………………………………………………………………………………………………………………………
productId=3333 productName=Del
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
Page 6 of 7 1/12/2017 1:17 PM
Ch=1
price=4000.00 productDescription=15 inch productId=555 productName=Monitor
……………………………………………………………………………………………………………………………………………………
price=5000.00 productDescription=17 inch productId=3333 productName=Monitor
……………………………………………………………………………………………………………………………………………………
price=4000.00 productDescription=Laptop productId=3333 productName=Del
……………………………………………………………………………………………………………………………………………………
price=200.00 productDescription=Optical Mouse productId=6666 productName=Mouse
……………………………………………………………………………………………………………………………………………………
ch=2 Description =”Desktop”
……………………………………………………………………………………………………………………………………………………
Desktop Not Found !
……………………………………………………………………………………………………………………………………………………
Ch=4
……………………………………………………………………………………………………………………………………………………
Invalid Option
………………………………………………………………………………………………………...............................................
Q 4. A- Correct the Error and find the output from the following code (5 points)
}// class
……………………………………………………………………………………………………………………………………………………
Name ID Number Department Position Yearsworked
……………………………………………………………………………………………………………………………………………………
___________________________________________
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
Eric Meyers 48899 Accounting Vice Pres 15
……………………………………………………………………………………………………………………………………………………
Anthony Jones 30119 IT Programmer 8
……………………………………………………………………………………………………………………………………………………
Carlos Rodgers 81674 Manufacturing Engineer 12
……………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………...............................................
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………...............................................