Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

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?


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


Write a Java code that will create a supportive class named, Conversion, which contains

three methods as specified below.


1) Method Name: Gallon2Liter(), Type: value-returning, Parameter: 1 parameter named g of double type, Operation: Return the result of g×3.78541178


2) Method Name: Inc2Cm(), Type: value-returning, Parameter: 1 parameter named i of doubletype, Operation: Return the result of i×2.54


3) Method Name: Pound2Kg(), Type: value-returning, Parameter: 1 parameter named p of double type, Operation: Return the result of p×0.45359237


In the “main” class, create an instance named “c1” of the “Conversion” class.


Use the “c1” instance to access all the three methods, “Gallon2Liter()”, “Inc2Cm()”, and “Pound2Kg()”, to convert the following values.

• 16.75 gallons

• 37.98 inches

• 140.27 pounds



LATEST TUTORIALS
APPROVED BY CLIENTS