Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5) If a method does not have a return statement, then A) it will produce a syntax error when compiled B) it must be
5) If a method does not have a return statement, then A) it will produce a syntax error when compiled B) it must be a void method C) it cannot be called from outside the class that defined the method D) it must be defined to be a public method E) it must be an int, double, float or String method 6) A variable whose scope is restricted to the method where it was declared is known as a(n) A) parameter B) global variable C) local variable D) public instance data E) private instance data 31 7) A class' constructor usually defines A) how an object is initialized B) how an object is interfaced C) the number of instance data in the class D) the number of methods in the class E) if the instance data are accessible outside of the object directly 8) Instance data for a Java class A) are limited to primitive types (e.g., int, float, char) B) are limited to Strings C) are limited to objects(e.g., Strings, classes defined by other programmers) D) may be primitive types or objects, but objects must be defined to be private E) may be primitive types or objects public class Student } private String name; private String major; private double gpa; private int credits; public Student (String n, String m, double g, int c) name = n; major = m; gpa = g; credits = c; } public String toString() return name + " " + major + " " + gpa + " " + credits 9) Which of the following could be used to instantiate a new Student sl? A) Student s1= new Student (); B) s1= new Student (); C) Student s1= new Student ("Jane", "cs", 3.333, 33); D) new Student s1 = ("Jane", "CS", 3.333, 33); E) new Student (s1); 10) Assume that another method has been defined that will compute and return the student's class rank (Freshman, Sophomore, etc). It is defined as: public String getClassRank () Given that s1 is a student, which of the following would properly be used to get sl's class rank?
Step by Step Solution
★★★★★
3.54 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
The detailed answer for the above question is provided below Answer 5 It must be a void method A void method is a method that does not have a return s...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started