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

IS5213 Data Science and Big Data Solutions

WEEK- 2 code  install.packages("dplyr") library(dplyr) Rajeshdf = read.csv('c:\\Insurance.csv') str(Rajeshdf)                        str(Rajeshdf) summary(Rajeshdf) agg_tbl <- Rajeshdf %>% group_by(Rajeshdf$JOB) %>%    summarise(total_count=n(),             .groups = 'drop') agg_tbl a = aggregate( x=Rajeshdf$HOME_VAL, by=list( Rajeshdf$CAR_TYPE), FUN=median, na.rm=TRUE ) a QUIZ 2. What famous literary detective solved a crime because a dog did not bark at the criminal? A). Sherlock Holmes 1.  In the Insurance data set, how many Lawyers are there? A).  1031 3. What two prefixes does the instructor use for variables when fixing the missing values? Select all that apply. A). IMP_ M_ 4. What is the median Home Value of a person who drives a Van? A).  204139 5. In the insurance data set, how many missing (NA) values does the variable AGE have? A) 7   1. What...

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

GE5093 Design Thinking All Quizzes

  GE---5093-1D2-FA-2021 - Design Thinking Home My courses 2021-FA GE---5093-1D2-FA-2021 Week 1 Reading Quiz 1 Started on Sunday, October 31, 2021, 2:04 PM State Finished Completed on Sunday, October 31, 2021, 2:30 PM Time taken 25 mins 58 secs Grade 8.00  out of 10.00 ( 80 %) Top of Form Question  1 Correct 1.00 points out of 1.00 Flag question Question text A critical finding of Edward Lorenz related to Design Thinking was: Select one: a. An application of the caterpillar effect b. The idea of deterministic chaos or the "Butterfly Effect" c. Business leaders enjoy chaos d. Statistical modeling of weather was fairly accurate in the long term Feedback Your answer is correct. The correct answer is: The idea of deterministic chaos or the "Butterfly Effect" Question  2 Incorrect 0.00 point...