The value of the variable a is 3:
String name;
name = "John";
int a = name.indexOf("h");
Select one:
True
False
The value of the variable a is 3: String name; name = "John"; int a =...
The String class has several methods that perform operations on the data or value associated with the String. Some of those methods are trim, charAt, substring, and indexOf Which of the following statements would be INCORRECT in Java? "Gus Ikeji".trim() would be "Gus Ikeji" Given: String name="John Doe"; name.charAt(1) would be 'o' Given: String name="John Doe"; name.substring(2, 6) would be "hn D" Given: String name="John Doe"; name.indexOf("ohn") would be 1 None of the above
This is my playlist class: class Playlist{ private String name; private int numberOfRecordings = 0; private int durationInSeconds = 0; private int MAX_PLAYLIST_SIZE; Recording recordingslist[]; Playlist(){ name = "Unknown"; MAX_PLAYLIST_SIZE = 5; recordingslist = new Recording[MAX_PLAYLIST_SIZE]; durationInSeconds = 0; } Playlist(String name, int size){ this.name = name; this.MAX_PLAYLIST_SIZE = size; recordingslist = new Recording[MAX_PLAYLIST_SIZE]; ...
#include <iostream #include <string> #ifndef ACCOUNT H #define ACCOUNT H class Account { public: Account(std::string, int); Account(){}; void deposit(int); void withdraw(int); int getBalance() const; 15 private: int balance{@}; std::string name{}; 18 19 20 Verdif - Account.cpp saved #include "Account.h" Account :: Account(std::string accountName, int startingBalance) : name{accountName) 4 5 if (startingBalance > 0) balance = startingBalance; B 10 void Account::deposit(int depositAmount) { if (depositAmount > 0) balance + depositAmount: ) 12 13 14 15 16 void Account::withdraw(int withdrawAmount) { If...
this
is java
4. (2 point each) What value will be assigned to the "answer" variable below? If the expression will not compile in Java, explain why. Write your answer on the line to the right. a. boolean answer = 6 < 2 || 7 > 3; b. boolean answer = true && false; c. boolean answer = ! (87 == 80); d. boolean answer = true > false; e. String name = "Daniel" ; boolean answer = ! (name.equals("Charles"));...
What is the final value of the count field? public class Person { private String name; private int age; private static int count=0; public Person(String name, int age) { this.name = name; this.age age; count++; } public static void main(String[] args) { Person a - new Person("John Doe". 35): Person b new Person("Jane Doe", 38): for(int i=0;i<5;i++) Person tempa
Write Junit test for the following class below: public class Player { public int turnScore; public int roundScore; public int lastTurnScore; public String name; public int chipPile; public Player (String name) { this.name = name; this.turnScore = 0; this.chipPile = 50; } public int getChip() { return chipPile; } public void addChip(int chips) { chipPile += chips; } public int getRoundScore() { return roundScore; } public void setRoundScore(int points) { roundScore += points; } public int getTurnScore() { return turnScore; ...
5. (12 points) Consider the following code fragment (part of a program): int index 3; String dna "ACTGTCA char nucleotide dna.charAt (index); Matching: For each term below, write the letter of the ONE choice that best matches the term. Data types Variables Literals Object Method ーParameter nde x a. coumt, nucleotide, and d b. 3 and "ACTGTCA c. int, char, and String d. index e. charAt f. dna na 6. (10 points) a. Wrte a statement that assigns true to...
1) int value = 24; int divisor = 5; value % divisor is a) 4 b) 1 c) 3 d) 0 e) 2 2) int value = 45; int divisor = 4; What is the result of value / divisor? a) 12 b) 11.25 c) 11 d) 10 3) Assume: int x[][] = {{ 1, 2 }, { 3, 4, 5 }, { 4, 5, 4, 9 }}; What are the values of? x.length? x[ 0 ].length? x[ 1 ].length?...
What value does this Processing code store in the s variable? String str = ""; int[] a = {4, 8, 7, 8}; for (int i = 0; i < a.length; i++) { str = a[i] + str; } String s = str;
The int variable x contains the number 7. Calculate the value of the following logical expressions. a. x < 10 && X >= -1 b. !x && x >= 3 C. X++ == 8 || x == 7 Oa: false b: true c: false ) a: true b: false c: false O a: false b: false c: true