Java questions and answers well illustrated.
Java questions and answers well illustrated. What do real world objects contain? - correct and behavior Where is a software object's state contained? - correct s (Java) or variables (C++) Where is a software object's behavior exposed? - correct ds (Java) or functions (C++) Hiding internal data from the outside world, and accessing it only through publicly exposed methods is known as data... - correct sulation A blueprint for a software object is called a... - correct Common behavior can be defined in a ___ and inherited into a ___ using the ___ keyword. - correct class, subclass, extends A collection of methods with no implementation is called an ___. - correct face A namespace that organizes classes and interfaces by functionality is called a ___. - correct ge The term API stands for ___? - correct cation programmer interface The term "instance variable" is another name for... - correct -static field - instance variables are specific to an object The term "class variable" is another name for ___. - correct c field - class variables are fixed and global across all instances of the class A local variable stores temporary state; it is declared inside a ___. - correct d - for example a counter in a loop int i=0; A variable declared within the opening and closing parenthesis of a method signature is called a ____. - correct eter What are the eight primitive data types supported by the Java programming language? - correct short long float double int char boolean Character strings are represented by the class ___. - correct .String An ___ is a container object that holds a fixed number of values of a single type. - correct Consider the following code snippet. arrayOfInts[j] > arrayOfInts[j+1] Which operators does the code contain? - correct rative operator "greater than" > arithmetic operator "plus" + Consider the following code snippet. int i = 10; int n = i++%5; a) What are the values of i and n after the code is executed? b) What are the final values of i and n if instead of using the postfix increment operator (i++), you use the prefix version (++i))? - correct answers.a) i=11, n=0 b) i=11, n=1 To invert the value of a boolean, which operator would you use? - correct answers."!" logical complement operator Which operator is used to compare two values, = or == ? - correct answers.== = is an assignment operator Explain the following code sample: result = someCondition ? value1 : value2; - correct someCondition is true then assign value1 to result else if someCondition is false then assign value2 to result In the following program, explain why the value "6" is printed twice in a row: class PrePostDemo { public static void main(String[] args){ int i = 3; i++; Sln(i); // "4" ++i; Sln(i); // "5" Sln(++i); // "6" Sln(i++); // "6" Sln(i); // "7" } } - correct answers.i++ is a postfix operator. 1 will be added to 1 after it's printed. ++i is a prefix operator. If it had been used, the println would have been "7" What is a compound assignment operator? - correct answers.You can also combine the arithmetic operators with the simple assignment operator to create compound assignments. For example, x+=1; and x=x+1; both increment the value of x by 1. The most basic control flow statement supported by the Java programming language is the ___ statement. - correct then The ___ statement allows for any number of possible execution paths. - correct h The ___ statement is similar to the while statement, but evaluates its expression at the ___ of the loop. - correct while end How do you write an infinite loop using the for statement? - correct ( ; ; ) { //do something } How do you write an infinite loop using the while statement? - correct (true) { //do something } Consider the following code snippet. if (aNumber >= 0) if (aNumber == 0) Sln("first string"); else
Written for
- Institution
- Java
- Course
- Java
Document information
- Uploaded on
- September 12, 2023
- Number of pages
- 8
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
Also available in package deal