Java | JSP | JSF Answers

Questions answered by Experts: 3 611

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

*Based on answer choices A-E, what is the code's output?


10. Given the following code, the output is __.


class Apple

{

int i;

Apple(int n) { i = n; }

}

class Sample

{

int j;

private Sample()

{

Apple a1 = new Apple(2);

a1.i++;

j = a1.i;

}

public static void main(String args[])

{

Sample s1 = new Sample();

System.out.println(s1.j);

}

}


A. 5

B. 4

C. 3

D. 2

E. 1


*Based on answer choices A-E, what is the code's output?


9. Given the following code, the output is __.


class Apple

{

int i;

Apple(int n) { i = n; }

}

class Sample

{

public static void main(String args[])

{

Apple a1 = new Apple(2);

System.out.println(a1.i);

a1.i++;

}

}


A. 5

B. 4

C. 3

D. 2

E. 1


*Based on answer choices A-E, what is the code's output?


8. Given the following code, the output is __.


class Apple

{

int i;

Apple() { i = 3; }

}

class Sample

{

public static void main(String args[])

{

Apple a1 = new Apple();

a1.i++;

System.out.println(a1.i);

}

}


A. 5

B. 4

C. 3

D. 2

E. 1


*Based on answer choices A-E, what is the code's output?


7. Given the following code, the output is __.


class Apple { public int i=0; }

class Fruits

{

public static void main(String args[])

{

Apple a1 = new Apple();

System.out.println(a1.i);

a1.i++;

}

}


A. 1

B. compiler error

C. runtime error

D. 2

E. 0


*Based on answer choices A-E, what is the code's output?


6. Given the following code, the output is __.


class Apple { static int i; }

class Fruits

{

public static void main(String args[])

{

Apple.i = 2;

Apple a1 = new Apple();

a1.i++;

System.out.println(a1.i);

}

}


A. 5

B. 4

C. 2

D. 3

E. 0


*Based on answer choices A-E, what is the correct option?


5. Which is an acceptable declaration of a Java nested class named "Outer"?


A. public class Outer { class Inner { } }

B. public class Outer { public class Inner { } }

C. public class Outer { static class Inner { } }

D. public class Outer { private class Inner { } }

E. All of the options


*Based on answer choices A-E, what is the correct option?


4. Given the following code, which is the correct way to create an object using the

parameterized constructor?


class Elmo

{

int age;

double length;

char model;

Elmo(int a, double l, char m) { age = a; length = l; model = m; }

}


A. Elmo e1 = new Elmo('Y', 5.6, 7);

B. Elmo e1 = new Elmo(5.6, 'Y', 7);

C. Elmo e1 = new Elmo(7, 'Y', 5.6);

D. Elmo e1 = new Elmo(5.6, 7, 'Y');

E. Elmo e1 = new Elmo(7, 5.6, 'Y');


*Based on answer choices A-E, what is the code's output?


3. Given the following code, which is an "instance variable" of the "Fruits" class?


class Fruits

{

public weight;

Fruits(double w) { weight = w; int height = 10}

public setHeight() { int h = 15; }

}


A. weight

B. height

C. w

D. h

E. All of the options


*Based on answer choices A-E, what is the correct option?


2. Assuming there exists a Java class named "Fruits", which can create an instance named "f1"

of the "Fruits" class that calls the default constructor for initialization?


A. Fruits(f1) = new Fruits();

B. Fruits f1 = new();

C. Fruits f1 = new Fruits();

D. Fruits *f1 = new Fruits();

E. Fruits *f1 = new Fruits;


*Based on answer choices A-E, what option is correct?


1. Which is an acceptable declaration of a Java class named "JavaCourse"?


A. static class JavaCourse { }

B. public class JavaCourse { }

C. private class JavaCourse { }

D. protected class JavaCourse { }

E. All of the options


LATEST TUTORIALS
APPROVED BY CLIENTS