Question: 5 MC question about programming ( java ) Consider the following class package uk.ac. rhul.mypackage; public class MyClass { private String s; protected int x;




Consider the following class package uk.ac. rhul.mypackage; public class MyClass \{ private String s; protected int x; int y; public double foo() \{ /l Some code here \} Select all the correct statements about the visibility of its instance variables and methods: Select one or more: a. The variable is visible to all classes in the package b. The variable is not visible to subclasses of that belong to the default package c. The method is not visible outside the package d. The variable is visible to any subclasses of Consider the following method public void printDivision(int m, int n ) \{ String output = ""; try \{ int d=m; output = "The result is:" +d; catch(ArtithmeticException ex) \{ output = "Division by 0!"; System. out.println(output); \} Select the correct statements about variable scopes: Select one or more: a. The scope of is the whole method b. The parameter is not visible inside the catch block c. The variable is visible inside the block Consider the following class public class MyClass \{ protected String myStr; public static int count; public MyClass (int initialValue) \{ count = initialValue; public void incrCount(int n ) \{ count +=n; String result = "The value of count is now: " count; System.out.println(result); \} For each variable mentioned below, select its kind: result Which of the following scenarios require you to document your code? Select one or more: a. Writing code for your final year project b. Publishing code on github for others to use c. Sharing your code with co-workers This question is about coding conventions in Java. Consider the following class public class myClass \{ protected int HelloCounter; public void hello() \{ for (int i=0;i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
