Question

Java programming 1) Which among the choices is the following Java expression equivalent to? !((b !=...

Java programming

1) Which among the choices is the following Java expression equivalent to?

!((b != 0) || (c <= 5)) 

Select one:

a)       (b != 0) && (c <= 5)

b)       (b == 0) && (c > 5)

c)       !((b <> 0) && (c <= 5))

d)       (! (b = 0)) && (! (c > 5))

e)       (b == 0) && (c <= 5)

2) The scope of a variable is an important feature in Java, the following variable was declared in the header of a Java class, what is the scope of this variable?

 public static int headerOne = 1;

Select one:

a) The variable is global and static enables unrestricted access to the variable from any JRE.

b) The variable is local to the class it was initialized and can only be accessed when an instance of the class has been created.

c) The variable is local and can only be accessed within the method it was initialized.

d) The variable is local to the class it was initialized and can be accessed without creating an instance of the class.

e) The variable is local to the method it was initialized and can only be accessed by an instances of that method.

Homework Answers

Answer #1

Question 1:
!((b != 0) || (c <= 5))
the choices is the Java expression equivalent to is (b == 0) && (c > 5)
So, answer is option b
Answer:
b)       (b == 0) && (c > 5)


Question 2:
public static int headerOne = 1;
the scope of this variable
The variable is local to the class it was initialized and can be accessed without creating an instance of the class.
So, answer is option d
Answer:
d) The variable is local to the class it was initialized and can be accessed without creating an instance of the class.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Java programming. 1) What, if anything, is wrong with the following Java code? void test(String x)...
Java programming. 1) What, if anything, is wrong with the following Java code? void test(String x) { switch (x) { case 1: break; case 2: break; case 0: break; default: break; case 4: break; } } Select one: a)Each case section must end with a break statement. b)The case label 0 must precede case label 1. c)There is nothing wrong with the Java code. d)The default label must be the last label in the switch statement. e)The variable x does...
Java programming. Fill the empty boxes with the Answer. 1) The Java compiler javac translates Java...
Java programming. Fill the empty boxes with the Answer. 1) The Java compiler javac translates Java source code into [Answer]. 2) In Java a class object can inherit the properties of a superclass by using the [Answer] keyword. 3) A(n) [Answer] method consists of the same method name but different number or types of parameters 4) In a class definition, the special method that is called to create an instance of that class is known as a/an [Answer] 5) The...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { flavor = s; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         System.out.println(pepper.getFlavor());     } } a. a class variable b. a constructor c. a local object variable d....
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*;...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*; import javax.swing.*; public class Clicker extends JFrame implements ActionListener {     int count;     JButton button;     Clicker() {         super("Click Me");         button = new JButton(String.valueOf(count));         add(button);         button.addActionListener(this);         setSize(200,100);         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         setVisible(true);     }     public void actionPerformed(ActionEvent e) {         count++;         button.setText(String.valueOf(count));     }     public static void main(String[] args) { new Clicker(); } } a. add(button);...
C Programming 1. Provide an equivalent of the java class in C class Example { public...
C Programming 1. Provide an equivalent of the java class in C class Example { public static int[][] question4(int n) { int[][] result = new int [n][n]; for(int i=1; i<=n; i+=1) for (int j=1; j<=n; j+=1) result[i][j] = (i*n)+j; return result; } public static void main(String[] args) { int[][] my array = question4(4); } } 2. Rewrite the following function using no loops, and only tail call recursion int min (int n, int[] input) { int i; int result; for...
1-To create an ArrayList of strings, which of the following is correct? `a ArrayList<String> list =...
1-To create an ArrayList of strings, which of the following is correct? `a ArrayList<String> list = new ArrayList<String>(); b ArrayList<String> list = new String<String>​[]; c ArrayList<String> list = new ArrayList<String>; d ArrayList​[String] list = new ArrayList​[String]; 2-All instance variables? a Are assigned a default value if they are not initialized b Must be initialized as part of their declaration c Are assigned an arbitrary value if they are not initialized d Must be initialized by the constructor 3-An instance method...
JAVA QUIZ Question 1 Which of the following is false about a "super" call in a...
JAVA QUIZ Question 1 Which of the following is false about a "super" call in a sub class's constructor? Select one: a. It must be the first statement in the constructor b. If you don't include it Java will c. If you don't include it you must have a 0 parameter constructor coded in the super class or no constructors coded at all in the super class d. The sub class constructor containing the super call and the called super...
The following is for a Java Program Create UML Class Diagram for these 4 java classes....
The following is for a Java Program Create UML Class Diagram for these 4 java classes. The diagram should include: 1) All instance variables, including type and access specifier (+, -); 2) All methods, including parameter list, return type and access specifier (+, -); 3) Include Generalization and Aggregation where appropriate. Java Classes description: 1. User Class 1.1 Subclass of Account class. 1.2 Instance variables __ 1.2.1 username – String __ 1.2.2 fullName – String __ 1.2.3 deptCode – int...
Java Programming COMP-228 LAB ASSIGNMENT #1 >> Apply the naming conventions for variables, methods, classes, and...
Java Programming COMP-228 LAB ASSIGNMENT #1 >> Apply the naming conventions for variables, methods, classes, and packages: - variable names start with a lowercase character for the first word and uppercase for every other word - classes start with an uppercase character of every word - packages use only lowercase characters - methods start with a lowercase character for the first word and uppercase for every other word Java Programming COMP-228 Exercise #1: [5 marks] Write a Java application using...
What is the output of the following Java program? public class Food {     static int...
What is the output of the following Java program? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { s = flavor; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         pepper.setFlavor("spicy");         System.out.println(pepper.getFlavor());     } } Select one: a. sweet b. 1 c. The program does not compile. d. 2 e. spicy...