Saturday , July 27 2024
Breaking News

CS101: Introduction to Computer Science 1 Exam Answers

CS101: Introduction to Computer Science 1 Exam Answers – Saylor Academy

  • Radio
  • Telegraph
  • FORTRAN
  • Vacuum tubes
  • Declarative
  • Exclamatory
  • Imperative
  • Question
  • Design, implementation, and testing
  • Requirements, construction, and testing
  • Design, construction, and implementation
  • Requirements, design, and implementation
  • Architecture
  • Flowchart
  • Procedure
  • Process
  • A set of general steps needed to perform a stage of the system life cycle
  • A set of tools that supports the activities of each stage of the system life cycle
  • A set of processes that guides the stages of the system development life cycle
  • A procedure that specifies detailed steps to perform a stage of the system life cycle
  • Functional
  • Imperative
  • Logic
  • Object
  • Lease the JDK
  • Purchase a JDK license
  • Purchase a copy of JDK
  • Accept the JDK license terms
  • sample.exe
  • sample.java
  • sample.class
  • sample.bytecode
  • Creativity
  • Curiosity
  • Ethics
  • Logic
  • It Increases software development costs and improves software quality
  • It decreases software development costs and improves software quality
  • It increases software life-cycle costs and decreases coupling of implementation and use
  • It decreases software life-cycle costs and increases coupling of implementation and use
  • Data and related object-oriented functions
  • A data type for a set of object-oriented programs
  • An object-oriented construct for saving the state of an object
  • A program construct used to define objects that share common attributes
  • B is a subclass of A, and C is a subclass of B
  • A is a subclass of B, and B is a subclass of C
  • A is a superclass of C, and B is a superclass of C
  • A is a superclass of B and C, and C is a subclass of A
  • Any text editor may be used to create a Java source program
  • Java source files can be of many file types, such as .txt, .java, .xml, or .docx
  • The file name of a Java source file must be the name of the only public class in the file
  • Word Processing software such as Microsoft Word is often used to create Java source programs
  • Include the Java package in the Java command line
  • Include the Java package in the Javoc command line
  • Import the Java package anywhere in the java source file
  • Import the Java class at the beginning of the java source file
  • short
  • int
  • logic
  • string
  • Using double, calculate 7 / 2
  • Using int, calculate 50000 + 5000000
  • Using short, calculate 1+2+3+……+200
  • Using unsigned int, calculate 100 – 5000
  • -2
  • -1
  • 0
  • 1
  • Technology
  • Through engineering to design.
  • Technology through engineering to design.
  • A compile error, since a string is immutable
  • Any Java object type
  • Any primitive data type
  • Only char and string types
  • Only primitive numeric types
  • (grade >= 70) && (grade < 80)
  • (grade <= 80) && (grade > 70)
  • !(grade < 70) || !(grade >79)
  • !((grade < 70) || (grade >79))
  • (A&amp;&amp; B) || !B
  • (A &amp;&amp; B) || !A
  • (A || B) &amp;&amp; (!A || B)
  • (B &amp;&amp; !A) || (A &amp;&amp; B)
  • They have the same form
  • They have the same values
  • They have the same truth tables
  • They have the same symbols in the same order
  • int x;
  • x = 1;
  • if then
  • puts
  • if (roomLength == 20) (if (visualAcuity – 1.0 < .001))

// checks for acuity equal to 1+-.001

    System.out.println(“Recommended font size for a room of length “

    + roomLength + ” is: ” +  DisplayPixel(roomLength, visualAcuity));

    //DisplayPixel is a function call that does the engineering calculation

  • if (roomLength == 20) if (visualAcuity – 1.0 < .001)

// checks for acuity equal to 1+-.001

    System.out.println(“Recommended font size for a room of length “

    + roomLength + ” is: ” +  DisplayPixel(roomLength, visualAcuity));

    //DisplayPixel is a function call that does the engineering calculation

  • if (roomLength == 20) {if (visualAcuity – 1.0 < .001)

// checks for acuity equal to 1+-.001

    System.out.println(“Recommended font size for a room of length ” +

    roomLength + ” is: ” +  DisplayPixel(roomLength, visualAcuity))};

    //DisplayPixel is a function call that does the engineering calculation

  • if (roomLength == 20) if (visualAcuity – 1.0 < .001)

// checks for acuity equal to 1+-.001

    {System.out.println(“Recommended font size for a room of length ” +

    roomLength + ” is: ” +  DisplayPixel(roomLength, visualAcuity))};

    //DisplayPixel is a function call that does the engineering calculation

  • Variables in expression and label1 can be global variables
  • label1 and the variables in expression must be of integer type
  • expression must evaluate to an integer and label1 must be an integer literal
  • If expression equals the variable label1, the statements of label1 are executed
  • int cost, ticket = 1; //value of ticket comes from System.in

for (; ticket != 0;) {

    cost = ticket;

    System.out.println(“ticket cost $” + cost);

    System.out.println(“ticket wins $” + cost * 10);

    ticket = value; // ticket given a value of 1, 5, 9 from input

    break;              

}

  • int cost, ticket; //value of ticket comes from System.in

for (; ticket != 0;) {

    cost = ticket;

    System.out.println(“ticket cost $” + cost);

    System.out.println(“ticket wins $” + cost * 10);

    ticket = 1; // ticket given a value of 1, 5, 9 from input

}

  • int cost, ticket = 1; //value of ticket comes from System.in

for (; ticket != 0;) {

    ticket = cost;

    System.out.println(“ticket cost $” + cost);

    System.out.println(“ticket wins $” + cost * 10);

    ticket = 1; // ticket given a value of 1, 5, 9 from input

    break;

}

  • int cost, ticket = 1; //value of ticket comes from System.in

for (;;;) {

    cost = ticket;

    System.out.println(“ticket cost $” + cost);

    System.out.println(“ticket wins $” + cost * 10);

    ticket = 1; // ticket given a value of 1, 5, 9 from input

}

  • By class data
  • By static data
  • By local variables
  • By method arguments
  • The program name in which the method is defined and a dot
  • The name of the class in which the method is defined and a dot
  • The name of an instance of the class in which the method is defined and a dot
  • The keyword new followed by the name of a class constructor for the method
  • An array is a java object
  • An array parameter is passed by reference
  • An array can be used to group different types
  • Components of an array are accessed by simple identifiers

Answer: Option D

  • for (Car findCar: inventory) {

    findCar.statusCar = “in”;

    System.out.print(findCar.typeCar + ” “);

    System.out.print(findCar.modelCar + ” “);

    System.out.println(findCar.statusCar + ” “);

}

  • int[] indexArray = { 0, 1, 2 };

for (int findCar: indexArray) {

    inventory[findCar].statusCar = “in”;

    System.out.print(inventory[findCar].typeCar + ” “);

    System.out.print(inventory[findCar].modelCar + ” “);

    System.out.println(inventory[findCar].statusCar + ” “);

}

  • Car[] indexArray = { inventory[0], inventory[1], inventory[2] };

for (int findCar: indexArray) {

    findCar.statusCar = “in”;

    System.out.print(findCar.typeCar + ” “);

    System.out.print(findCar.modelCar + ” “);

    System.out.println(findCar.statusCar + ” “);

}

  • Car[] indexArray = { inventory[0], inventory[1], inventory[2] };

for (Car findCar: inventory) {

    findCar.statusCar = “in”;

    System.out.print(findCar.typeCar + ” “);

    System.out.print(findCar.modelCar + ” “);

    System.out.println(findCar.statusCar + ” “);

}

  • System.read
  • System.err
  • System.util.scanner.nextInt()
  • System.util.scanner.nextLine()
  • When data used by a program is useful for other programs
  • When data used by a program is dependent on the program
  • When you want the program to write its data faster than to external file
  • When you want the program to read its data faster than from an external file
  • The Scanner class can be used to read byte data
  • The Scanner class can be used to read input data
  • Data can only be read from a file using the FileReader class.
  • The Scanner class can only be used to read data from the keyboard
  • Hello World
  • It would give a null pointer exception
  • It would give an array store exception
  • It would give an out of bounds exception
  • 3, 7, 11
  • 3, 7, 9, 13
  • 3, 7, 11, 13
  • 3, 7, 9, 11, 13
  • Each atomic statement is assigned the value True
  • Each atomic statement is assigned the value False
  • If an atomic statement is true, it is assigned the value True; otherwise it is False
  • A sequence of n atomic statements is assigned 2n permutations of True and False
  • GUI
  • RAM
  • Cache
  • Transistor
  • Design and implementation
  • Implementation and Testing
  • Requirements and Design
  • Requirements and Testing
  • run sample
  • java sample
  • run sample.class
  • java sample.class
  • To make decisions
  • To discover new information
  • To execute sets of instructions
  • To recognize problems and create solutions
  • Objects and messages
  • Functions and operations
  • Predicates and operations
  • Data and control statements
  • A set of values for a data type
  • A data type and its associated programs
  • A construct that characterizes a member of a class
  • A set of constructs that communicate via messages
  • java Hello
  • javac Hello
  • java Test.java
  • javac Test.java
  • A collection of classes used by a program
  • A collection GUI tools used by a program
  • A collection of objects that make up a program
  • A collection of programs used by an application
  • 231
  • 264
  • (232)-1
  • (264)-1
  • binary
  • decimal
  • double
  • long
  • !(x > y)
  • -x <= -y
  • (x < y) && (x = y)
  • (x +1) >= (y + 1)
  • if (status = ‘e’) {

    if (credits >= 60)

        System.out.println(“student:”, studentID);

};

  • (if status == ‘e’) {

    (if credits >= 60)

    System.out.println(“student:”, studentID);

};

  • if (status = ‘e’) {

    if (credits! < 60)

        System.out.println(“student:”, studentID);

};

  • int age, weight;

(age >= 18 && age <= 60) && (weight >= 110))

  • long age, weight;

(age >= 18. && age <= 60.) && (weight >= 110.)

  • int ageInMonths ; long weight;

(ageInMonths >= 216 && ageInMonths <= 720) && (weight >= 110.)

  • int ageInMonths; long weight;

(ageInMonths >= 216 && ageInMonths <= 720) && (weight > 109.9999)

  • (weight >= 110) && (age >= 17) && (iron2 >12.0)
  • ((weight >= 110) && (age >= 17)) || ((iron1 >= 12.0) || (iron2 >= 12.0))
  • ((weight >= 110) && (age >= 17)) && ((iron1 >= 12.0) || (iron2 >= 12.0))
  • ((weight >= 110) && (age >= 17) && (iron1 >12.0)) || ((weight >= 110) && (age >= 17) && (iron2 >12.0))
  • int routeNum = 95;

if (routeNum % 2 == 0)

    System.out.println(“Route ” + routeNum + ” runs east-west”)

else System.out.println(“Route ” + routeNum + ” runs north-south”);

  • int routeNum = 95;

if (routeNum % 2 == 0)

    System.out.println(“Route ” + routeNum + ” runs east-west”);

else System.out.println(“Route ” + routeNum + ” runs north-south”);

  • int routeNum = 95;

(if routeNum % 2 == 0)

    System.out.println(“Route ” + routeNum + ” runs east-west”);

else System.out.println(“Route ” + routeNum + ” runs north-south”);

  • int routeNum = 95;

if (routeNum % 2 == 0)

    System.out.println(“Route ” + routeNum + ” runs east-west”);

else {

    System.out.println(“Route ” + routeNum + ” runs north-south”);

}

  • label 3
  • case 2
    label 3
  • It would give a compile error
  • It would give a runtime error
  • A calls any method of B
  • A calls a public method of B
  • A calls one of its methods which interfaces with B
  • A calls a class script, which in turn shares data with B
  • public class Main {

    public static void main(String[] args) {

        changeInstanceData(4);

    }

}

  • public static void main(String[] args) {

    instanceData = 4;

}

  • public static void main(String[] args) {

    ClassName obj = new ClassName();

    obj.instantData = 4;

}

  • public static void main(String[] args) {

    ClassName obj = new ClassName();

    obj.ChangeInstanceData(4)

}

  • An enhanced for-loop uses subscripts to incrementally access elements of an array.
  • An enhanced for-loop has a concise structure related syntax for iterating over an array.
  • An enhanced for-loop generates validity checks for indices used in the body of the loop.
  • An enhanced for-loop uses for-loop features together with structure related features to iterate over an array.
  • String s1 = ” CUSTOMER”;

String s2 = ” NAME”;

String s3 = ” ID#”;

System.out.println(“%2$s %1$s”, “s1+s2”, “s3”);

  • String s1 = ” CUSTOMER”;

String s2 = ” NAME”;

String s3 = ” ID#”;

System.out.println( % 2 $s % 1 $s “, s1+s2, s3.;   

  • String s1 = ” CUSTOMER”;

String s2 = ” NAME”;

String s3 = ” ID#”;

String heading = String.format(“%2$s %1$s”, s1 + s2, s3.;

System.out.println(heading);

  • String s1 = ” CUSTOMER”;

String s2 = ” NAME”;

String s3 = ” ID#”;

String heading = String.format(“%2$s %1$s”, “s1+s2”, “s3”);

System.out.println(heading);

  • import java.io.*;

class WriteCarFile {

    public static void main(String[] args) throws IOException {

        String carfileName = “CarInventory.txt”;

        writer.open();

        FileWriter writer = new FileWriter(carfileName, true);

        writer.write(“4 LCAR Audi 0 in\n”);

        writer.write(“5 FFAR Suburban 0 in\n”);

        writer.write(“6 PPAR Ford150 0 in\n”);

        writer.close();

    }

}

  • import java.io.*;

class WriteCarFile {

    public static void main(String[] args) {

        String carfileName = “CarInventory.txt”;

        FileWriter writer = new FileWriter(carfileName, false);

        writer.write(“4 LCAR Audi 0 in”);

        writer.write(“5 FFAR Suburban 0 in”);

        writer.write(“6 PPAR Ford150 0 in”);

        writer.close();

    }

}

  • import java.io.*;

class WriteCarFile {

    public static void main(String[] args) throws IOException {

        String carfileName = “CarInventory.txt”;

        FileWriter writer = new FileWriter(carfileName, true);

        writer.write(“4 LCAR Audi 0 in\n”);

        writer.write(“5 FFAR Suburban 0 in\n”);

        writer.write(“6 PPAR Ford150 0 in\n”);

        writer.close();

    }

}

  • import java.io.*;

class WriteCarFile {

    public static void main(String[] args)

    {

        String carfileName = “CarInventory.txt”;

        FileWriter writer = new FileWriter(carfileName, true);

        writer.write(“4 LCAR Audi 0 in\n”);

        writer.write(“5 FFAR Suburban 0 in\n”);

        writer.write(“6 PPAR Ford150 0 in\n”);

        writer.close();

    }

}

  • At run-time
  • At design time
  • At compile time
  • During requirements specification
  • Every method
  • A method that might cause an exception
  • Only the methods that have a ‘catch’ clause
  • A method that might cause an exception, and each method in its chain
  • ‘null’
  • Unspecified
  • False or True
  • False and True
  • When it is not possible for P or Q to be true and R false
  • When it is not possible for P and Q to be true and R false
  • When it is not possible for P or Q to be false and R true
  • When it is not possible for P and Q to be false and R true
  • Objects
  • Network support
  • Memory management
  • Communication support
  • To test Java programs
  • To analyze Java programs
  • To compile Java programs
  • To document Java programs
  • It promotes platform independence
  • It promotes program interdependence
  • It allows for encapsulation of data and procedures
  • It has greater execution efficiency compared to older paradigms
  • public, static, String, void
  • args, public, static, String, void
  • main, public, static, String, void
  • args, main, public, static, String, void
  • It can be anywhere in the Java source file
  • It makes the names of external classes visible
  • It includes external classes in a java source file
  • Together with *, it makes a class and subclasses visible
  • 1
  • x
  • x+1
  • An error
  • y
  • null
  • blank
  • empty
  • label 1
  • label 1
    label 2
  • It would give a compile error
  • It would give a runtime error
  • int array1[4];
  • int[4] array1;
  • int[] array1 = new int[4];
  • int array1[] = new Array[4];

Answer: Option A

Answer: Option D

  • A text editor
  • The JRE interpreter
  • The JDK Java editor
  • Windows Visual Studio
  • Inheritance
  • Constructors
  • Polymorphism
  • Declaration keywords
  • False
    False
  • False
    True
  • True
    False
  • True
    True
  • They define the data that is stored
  • They change the data that is stored
  • They determine the order in which code is executed
  • They declare the name and type of data that is input
  • Transacting an online bank deposit
  • Performing a computation specified by an equation
  • Selecting the next statement to execute based on a condition
  • Executing a block of code repetitively using different data values
  • String str = “John”;

str.length();

  • String str = “John”;

String.length(str);

  • String str = new String(“John”);

length(str);

  • String str = new String(“John”);

String.length(str);

  • for (int row, col = 0; row < 100 and col < 3; row++) {

    if (inventory[row][1] == “mid” &&

        inventory[row][2] == “chv”);

}

  • for (int row, col = 0; row < 100 and col < 3; row++) {

    if (inventory[row][col] == “mid” &&

        inventory[row][col + 1] == “chv”);

}

  • for (int row, col = 0; col < 3 && row < 100; col++) {

    if (inventory[col][row] == “mid” &&

        inventory[col][2] == “chv”);

}

  • for (int row, col = 0; col < 3 && row < 100; col++) {

    if (inventory[col][row] == “mid” &&

        Inventory[col][row + 1] == “chv”);

}

  • mystring

ok

123

mystring

  • mystring

mystring

ok

123

123

  • mystring

123

ok

123

  • It would give an execution error
  • define and allocate a file object

use the object’s write method to write string fields

use the object’s close method to close the file

  • construct a FileWriter object with a file name

use the objects write method to write character lines to the file

use the objects close method to close the file

  • declare a file name

construct a FileWriter object with that defined file name

use a FileWriter method to write string lines to the file

use a FileWriter method to close the file

  • define a file name

use the FileWriter open method to allocate a file with that name

use the FileWriter write method to write byte to that file

use the FileWriter close method to close the file

  • Scanner methods can be used to read a text file
  • A File class object is attached to a Scanner object
  • A File class method can be used to check for end of file
  • Scanner.class methods do not throw file related checked exceptions
  • Composition of detailed components
  • Decomposition into major components
  • Hierarchy of components and subcomponents
  • Language for forming instructions that control components
  • Abstraction
  • Composition
  • Decomposition
  • Language
  • .html
  • .java
  • .jdoc
  • .txt
  • A class
  • An array
  • An object
  • A primitive data type
  • True
  • False
  • It would give a syntax error
  • It would give a runtime error
  • A &amp;&amp; !B
  • !A &amp;&amp; B
  • !A &amp;&amp; !B
  • !(A &amp;&amp; B)
  • ‘do’ statements
  • ‘do’ and ‘do – until’ statements
  • ‘while’, ‘do – until’, and ‘for’ statements
  • ‘while’, ‘do – while’, and ‘for’ statements
  • Conditions
  • Counters
  • Sentinels
  • Updaters

Answers: Option A or B

  • Machine independence
  • Many low level facilities
  • An object model, like C++
  • Manual memory management
  • They improve the performance of the process
  • They remove the people involved in the process
  • They generate ideas for how to streamline the process
  • They decrease the amount of data involved in the process
  • A category of data that is part of the Java language
  • A user-defined class that declares a set of variables
  • A user-defined object that declares a set of identifiers
  • A piece of information needed by the Java Virtual Machine
  • 0
  • 0.5
  • 1/2
  • 1
  • Propositional logic
  • First-order predicate logic
  • Second-order predicate logic
  • Higher-order predicate logic
  • a
  • ‘a’
  • It would give a compile error
  • It would give a runtime error
  • A
  • B
  • (!A OR B ) AND (A OR !B)
  • (!A AND !B) OR (A AND !B)
  • import java.util.*
  • long size = 1234567890;
  • System.out.println(“Hello world!”);
  • try {System.out.println(s.substring(start))};
  • C is an object
  • CQ is an object
  • CQ is a subclass of C
  • CQ is a parent of class C
  • 1.1
  • integer 1.1
  • It would give a run-time exception
  • It would give a compile format error
  • The second generation, which was characterized by transistors
  • The third generation, which was characterized by integrated circuits
  • The fourth generation, which was characterized by very-large-scale integration
  • The fifth generation, which was characterized by massive parallel hardware
  • public double circum(r) {

    double c;

    return c = 2 * pi * radius;

};

  • public double circum(radius) {

    double c = 2 * pi * radius;

};

  • public double circum() {

    double c;

    return c = 2 * pi * radius;

};

  • public void circum() {

    double circum = 2 * pi * radius;

    System.out.println(“arrived ” + circum);

};

  • They have the same class data and behavior
  • They have different class data and behavior
  • They have the same class data and different behavior
  • They have different class data and the same behavior

About Clear My Certification

Check Also

Financial Derivatives and Risk Management Certificate

Get Financial Derivatives and Risk Management Certificate from The Digital Adda which you can share …

Leave a Reply

Your email address will not be published. Required fields are marked *