1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
artcher [175]
3 years ago
10

Which of the following class definitions is correct in Java?(i)public class Student{private String name;private double gpa;priva

te int id;public void Student(){name = "";gpa = 0;id = 0;}public void Student(String s, double g, int i){set(s, g, i);}public void set(String s, double g, int i){name = s;gpa = g;id = i;}public void print(){System.out.println(name + " " + id + " " + gpa);}}(ii)public class Student{private String name;private double gpa;private int id;public Student(){name = "";gpa = 0;id = 0;}public Student(String s, double g, int i){set(s, g, i);}public void set(String s, double g, int i){name = s;gpa = g;id = i;}public void print(){System.out.println(name + " " + id + " " + gpa);}}1. Both (i) and (ii)2. None of these3. Only (ii)4. Only (i)
Computers and Technology
1 answer:
Soloha48 [4]3 years ago
4 0

Answer:

The answer is "Option 3".

Explanation:

In the given question the code (ii) is correct because in the class definition class "Student" defines a constructor that does not use any return type. and code (i) class definition the class "Student" defines a constructor that uses return type void which is not allowed in the constructor. and other options are not correct that can be described as follows:

  • In option 1, only code (ii) is correct.
  • In option 2, code (ii) is correct that's why it is not correct.
  • In option 4, it is not correct, because it uses void return type.

You might be interested in
Which of the following is not considered a system component that can be found inside a computer? A-CPU B-RAM C-PCIe graphics ada
Julli [10]

The answer is C) PCIe graphics adapter, because it is not required for the computer to work.

8 0
3 years ago
When planning the structure of a spreadsheet, columns are for _______ items and rows are for _______ items.
Alisiya [41]
I believe the correct answer from the choices listed above is option D. <span>When planning the structure of a spreadsheet, columns are for group items and rows are for single items. Hope this answers the question. Have a nice day.</span>
5 0
3 years ago
Read 2 more answers
Djdjdjdjdjdjdjdjdjjdjdjdjdjdjdjdjdjdjdj
DanielleElmas [232]
Shorty a bad bleep .
7 0
3 years ago
Read 2 more answers
A(n) _____ chart is drawn on the same worksheet as the data.
Harrizon [31]
The answer is An embedded chart
6 0
4 years ago
What are the best 3 xbox 360 games ?​
Andru [333]
Halo
GTA
Call of duty
5 0
4 years ago
Read 2 more answers
Other questions:
  • Which statement reflects inherent bias in reading and learning about our world?
    12·1 answer
  • Which protocols are TCP/IP application layer protocols? (choose all that apply)
    5·2 answers
  • What will happen if Sam goes to the View menu, clicks Toolbars, and then clicks Picture?
    12·2 answers
  • What information should be included in the closing paragraph of a thank-you letter? a. Mention skills that were omitted during t
    6·2 answers
  • Please check my answer! (Java)
    13·1 answer
  • T F A stub is a dummy function that is called instead of the actual function it<br><br> represents.
    7·1 answer
  • Which of the following is the MOST sensitive Personally Identifiable Information (PII) and should be shared cautiously and only
    8·1 answer
  • Which of these trade-offs occur in a memory hierarchy?
    15·1 answer
  • In English there are five vowel letters in the alphabet: A, E, I, O, U. For the purposes of this exercise we won't count Y as a
    5·1 answer
  • Pls need this asap
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!