Skip to main content

IS5103 Week 6 (Quiz)

 Quiz


1. Analyze the following code:

public class Test extends A {
public static void main(String[] args) {
Test t = new Test();
t.print();
}
}

class A {
String s;

A(String s) {
this.s = s;
}

public void print() {
System.out.println(s);
}
}

A). 1. The program would compile if a default constructor A(){ } is added to class A explicitly.

    2. The program has an implicit default constructor Test(), but it cannot be compiled, because its super class does not have a default constructor. The program would compile if the constructor in the class A were removed.


2. What is the output of running class C?

class A {
public A() {
System.out.println(
"The default constructor of A is invoked");
}
}

class B extends A {
public B() {
System.out.println(
"The default constructor of B is invoked");
}
}

public class C {
public static void main(String[] args) {
B b = new B();
}
}

A). "The default constructor of A is invoked" followed by "The default constructor of B is invoked"

 

3). Analyze the following code:

public class Test {
public static void main(String[] args) {
B b = new B();
b.m(5);
System.out.println("i is " + b.i);
}
}

class A {
int i;

public void m(int i) {
this.i = i;
}
}

class B extends A {
public void m(String s) {
}
}


A). The method m is not overridden in B. B inherits the method m from A and defines an overloaded method m in B.


4. What is the output of the following code?

public class Test {
public static void main(String[] args) {
new Person().printPerson();
new Student().printPerson();
}
}

class Student extends Person {
@Override
public String getInfo() {
return "Student";
}
}

class Person {
public String getInfo() {
return "Person";
}

public void printPerson() {
System.out.println(getInfo());
}
}


A). Person Student


5. Given two reference variables t1 and t2, if t1 == t2 is true, t1.equals(t2) must be ________.


A). true


6. Analyze the following code

// Program 1:
public class Test {
public static void main(String[] args) {
Object a1 = new A();
Object a2 = new A();
System.out.println(a1.equals(a2));
}
}

class A {
int x;

public boolean equals(A a) {
return this.x == a.x;
}
}


// Program 2:
public class Test {
public static void main(String[] args) {
A a1 = new A();
A a2 = new A();
System.out.println(a1.equals(a2));
}
}

class A {
int x;

public boolean equals(A a) {
return this.x == a.x;
}
}


A)Program 1 displays false and Program 2 displays true.


7. For the questions below, consider the following class definition:

public class AClass
{

protected int x;

 

protected int y;

 

public AClass(int a, int b)

 

{

 

x = a;

 

y = b;

 

}

 

public int addEmegg

 

{

 

return x + y;

 

}

 

public void changeEmegg

 

{

 

x++;

 

y--;

 

}

 

public String toStringegg

 

{

 

return "" + x + " " + y;

 

}

}

A). Redefine addEm to return the value of z + super.addEmegg, but leave changeEm alone



8). For the questions below, use the following partial class definitions:

public class A1
{

public int x;

 

private int y;

 

protected int z;

...
}

public class A2 extends A1
{

protected int a;

 

private int b;

...
}

public class A3 extends A2
{

private int q;

...
}

A). x, z, a, b


9. If class AParentClass has a protected instance data x, and AChildClass is a derived class of AParentClass, then AChildClass can access x but can not redefine x to be a different type.

A). False


10. If classes C1 and C2 both implement an interface Cint, which has a method whichIsIt, and if C1 c = new C1 ; is performed at one point of the program, then a later instruction c.whichIsIt ; will invoke the whichIsIt method defined in C1.


A).  False




















Comments

Popular posts from this blog

IS5203 Type 2 Post Assessment and Final Quiz

  Carlos has just created a new subnet for the finance department. He needs to be able to allow the employees in finance to retrieve files from the sales server, which is located in another subnet. Which of the following OSI model layers would it be necessary to categorize the device into? a. Layer 4 b. Layer 6 c. Layer 2 d. Layer 3 All of the cubicles in a company's office have cables that run up to the ceiling and across to an IDF. Inside the IDF, they connect directly to the latest generation switch available from the networking equipment vendor that they have chosen. Which of the following describes the physical topology most likely in use? a. mesh

GE5103-2 Project Management [Aug 23 Syllabus]

    Some of the advantages of using time boxes and cycles in project coordination efforts include creating urgency, measuring progress, and allowing for predictable measurements. A)        True 2.    Even though most project managers are not contract specialists, they need to understand the process well enough to coordinate with the team. For the current assignment, you are looking at a short-term and small effort with a contractor of just a few hours without significant clarity. Which of the following would be the most applicable contract to use in this situation? A)        Time and materials 3. The project you are working on has had modifications to the plan from the start and even how the project is run. Project governance covers all of the 3 following except: A)        Naming The project manager 4. Of the following, which is most likely a trigger condition defined early in the project? A) Alerting Governance board if 10 percent over schedule 5. Of the following options, which stand

GE5163 Week8 ( Final Exam ) Quize's

  A process or product that is insensitive to normal variation is referred to as being Select one: a. in specification b. capable c. robust d. out of control Feedback Your answer is correct. A completed failure mode and effects analysis (FMEA) results in the following assessment rating.      Occurrence = 4      Severity = 8      Detection = 10 What is the risk priority number (RPN) for this FMEA? Select one: a. 42 b. 22 c. 320 d. 120 Feedback Your answer is correct. In a visual inspection situation, one of the best ways to minimize deterioration of the quality level is to: Select one: a. have a program of frequent eye exams. b. retrain the inspector frequently. c. add variety to the task. d. have a standard to compare against as an element of the operation. Feedback Your answer is correct. Which of the following elements is least necessary to a good corrective action feedback report? Select one: a. What caused the failure b. Who caused the failure c. What correction has been made d. Wh