Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4. Complete the code, drawing a solid circle (with the current color, whatever i

ID: 666967 • Letter: 4

Question

4. Complete the code, drawing a solid circle (with the current color, whatever it is) so that its diameter is 200, and the coordinates of its center are ( 250, 150 )

public void paint( Graphics g )

{

// your code goes here

}

5. The access modifier of constructors should be _________________

9. Write a loop to output the word EXAM 99 times

11. Write the code to compute and output how many times the value 99 is found in an array of integers named numbers

13. The variable numbers is a 2-dimensional array of type int; output all of its elements that are strictly greater than 10

14. What is the error and why is there an error in the code below?

public class XYZ

{

public static final int A = 9;

public abstract void foo1( );

public int foo2( )

{

return 5;

}

}

15. When we read objects from a file using the readObject method, what happens when the end of the file is reached?

16. What is the output of the following sequence?

Scanner scan = new Scanner( System.in );

int number = 0;

try

{

number = scan.nextInt( );    // User enters 12, hits ENTER

System.out.println( "1: " + number );

number = scan.nextInt( );    // User enters 56, hits ENTER

System.out.println( "2: " + number );

number = scan.nextInt( );     // User enters 99ABC, hits ENTER

System.out.println( "3: " + number );

}

catch( Exception e)

{

String s = scan.nextLine( );

System.out.println( "4: " + number );

}

finally

{

number = scan.nextInt( ); // User enters 100, hits ENTER

System.out.println( "5: " + number );

}

17. In the BorderLayout class, what are NORTH, SOUTH, EAST, WEST, and CENTER?

Explanation / Answer

4)

import java.lang.*;
import java.util.*;
import java.util.List;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;

public class DrawCircle extends Frame {

public void paint(Graphics g) {
     Graphics2D ga = (Graphics2D)g;
     ga.setPaint(Color.red);
     ga.DrawCircle(100,100,250,150);
}
             
public static void main(String args[])
{
      DrawCircle frame = new DrawCircle();     
      frame.addWindowListener(
      new WindowAdapter()
      {
         public void windowClosing(WindowEvent we)
         {
            System.exit(0);
         }
      }
      );
          
      frame.setSize(100,100);
      frame.setVisible(true);
   }
}


5) The access modifier of constructors should be private.

6) Write a loop to output the word EXAM 99 times

   #include<stdio.h>
main()
{
int i = 1;
while (i < = 100)
{
printf("Exam ");
i = i +1;
}
return(0);
}

15) When we read objects from a file using the readObject method, what happens when the end of the file is reached? IOException EOF

17) Class BorderLayout arranges the components to fit in the five regions: east, west, north, south and center. Each region is can contain only one component and each component in each region is identified by the corresponding constant NORTH, SOUTH, EAST, WEST, and CENTER.

static String CENTER -- The center layout constraint (middle of container).
static String EAST -- The east layout constraint (right side of container).
static String NORTH -- The north layout constraint (top of container).
static String SOUTH -- The south layout constraint (bottom of container).
static String WEST -- The west layout constraint (left side of container).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote