Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Which of the following are valid ways to declare an array? A. int[] numbers = {1, 2, 3, 4, 5}; B. int[] numbers; numbers

1.

Which of the following are valid ways to declare an array?

A. int[] numbers = {1, 2, 3, 4, 5}; 
B. int[] numbers; numbers = new int[10]; 
C. int[] numbers = new int[10]; 
D. int[5] numbers = {1,2 ,3, 4, 5};

2.

Consider the following class:

class Employee { public int salary; public Employee(int annualSalary) { salary = annualSalary; } public Employee(int weeklySalary, int numberOfWeeks) { salary = weeklySalary * numberOfWeeks; } } 

Which of the following are valid ways to create an instance of this class?

A. Employee e1 = new Employee(30000);
B. Employee e2 = new Employee(500, 52);
C. Employee e4 = new Employee("Joe Smith");
D. Employee e3 = new Employee();

3.

Java provides file operations in which of the following?

A. java.io.PrinterWriter.*
B. java.util.*
C. java.io.*
D. java.io.util*

4.

Consider the following class:

class MyClass { private static int x = 20; private static int y; private static int z = 25; private int abc = 1000; public void setFields() { x = 3; y = 4; z = 5; abc += 1000; } public static void modFields() { x = 7; y = 9; z = 10; } }

Which of the following would produce an error if used in the Main method of a program that includes this class?

A. MyClass mc = new MyClass(); mc.modFields(); 
B. MyClass.setFields();

C. MyClass.modFields(); 
D. MyClass mc = new MyClass(); mc.setFields();

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions