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
Bunch of points!!!!!!! help pls
alex41 [277]
Most likely B. Photographs.

Hope this helps!

Have a good day!
4 0
3 years ago
Read 2 more answers
What is a good monitor for console gaming? (Any price)
likoan [24]

Answer:

I personally use a alienware

Explanation:

7 0
3 years ago
Read 2 more answers
What type of cable is used to connect a workstation serial port to a cisco router console port?
butalik [34]

a <span>Ethernet-<span>Cable is a how to put it together</span></span>

<span><span /></span>

6 0
3 years ago
When a computer is the.................of an attack, it is used as an active tool to conduct the attack
BARSIC [14]

Answer:

Attack is an intentional or unintentional act that causes damage or compromises information of systems supporting it.When a computer is the subject of an attack, it is used as an active tool to conduct the attack.

On the other hand, when a computer is the entity being attacked, it is the object of an attack.

3 0
2 years ago
#include
rodikova [14]

Output

SORTED                                                                                                                                

4 7 10 69                                                                                                                              

                                                                                                                                     

SORTED                                                                                                                                

10 9 7 3                                                                                                                              

                                                                                                                                     

NOT SORTED                                                                                                                            

19 12 23 7                                                                                                                            

                                                                                                                                     

SORTED                                                                                                                                

5 5 5 5

Code

//The added part is in the bottom

#include <iostream>

using namespace std;

const int SIZE = 4;

bool isSorted (const int arr[], int size);

bool isNonDecreasing (const int arr[], int size);

bool isNonIncreasing (const int arr[], int size);

void printArr (const int arr[], int size);

int

main ()

{

 int test1[] = { 4, 7, 10, 69 };

 int test2[] = { 10, 9, 7, 3 };

 int test3[] = { 19, 12, 23, 7 };

 int test4[] = { 5, 5, 5, 5 };

 if (!isSorted (test1, SIZE))

   cout << "NOT ";

 cout << "SORTED" << endl;

 printArr (test1, SIZE);

 if (!isSorted (test2, SIZE))

   cout << "NOT ";

 cout << "SORTED" << endl;

 printArr (test2, SIZE);

 if (!isSorted (test3, SIZE))

   cout << "NOT ";

 cout << "SORTED" << endl;

 printArr (test3, SIZE);

 if (!isSorted (test4, SIZE))

   cout << "NOT ";

 cout << "SORTED" << endl;

 printArr (test4, SIZE);

 return 0;

}

bool

isSorted (const int arr[], int size)

{

//Added part

 if (isNonDecreasing (arr, size) || isNonIncreasing (arr, size))

   {

     return true;

   }

 else

   {

     return false;

   }

}

bool

isNonDecreasing (const int arr[], int size)

{

 for (int i = 0; i < (size - 1); i++)

   {

     if (arr[i] > arr[i + 1]) //It compares the n value with the n-1 value and output

{

  return false;

  break;

}

   }

 return true;

}

bool

isNonIncreasing (const int arr[], int size)

{

 for (int i = 0; i < (size - 1); i++)

   {

     if (arr[i] < arr[i + 1]) //It compares the n value with the n-1 value and output reautilization of previous function by replacing only “<”

{

  return false;

  break;

}

   }

 return true;

}

void

printArr (const int arr[], int size)

{

 for (int i = 0; i < size; i++)

   cout << arr[i] << " ";

 cout << endl << endl;

}

7 0
3 years ago
Other questions:
  • Jake is photographing his pet puppy. He wants to preview the image the camera will capture. What part of the camera that is insi
    6·2 answers
  • ____ indicates the number of pixels that a computer uses to display the letters, numbers, graphics, and background on a screen.
    12·2 answers
  • Using ajax technologies and apis, websites and applications can pull information from a variety of sources in order to create __
    8·1 answer
  • 1. Which plot element is typically the turning point and the most intense moment of a story? (1 point)
    11·2 answers
  • Texture fills are available to add as a slide background true or false
    7·2 answers
  • For each 8-bit data frame the layer uses a generator polynomial G(x) = x4+x2+ x+1 to add redundant bits. What is the sequence of
    11·1 answer
  • What framework provides a simple API for performing web tasks?
    13·1 answer
  • How can i setup a mesage room and also want to hangout ??????
    10·1 answer
  • After a Hacker has selects her target, performed reconnaissance on the potential target's network, and probed active Internet Ad
    13·1 answer
  • 8. Give regular expressions with alphabet {a, b} for
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!