0

programming languages Online Quiz - 164

Description: programming languages Online Quiz - 164
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

While using CLASS and BY Statements in PROC MEANS one should keep in mind :

  1. Use the CLASS Statement when number of observation >10000

  2. Use the By Statement when number of observation <1000

  3. Using the BY Statement requires that the input data set be sorted by the values of the classification variables

  4. Using the CLASS Statement requires that the input data set be sorted by the values of the classification variables


Correct Option: C

Which of the following code gives the output : The MEANS Procedure Analysis Variable : totrev Mean Sum 753.82 12349156.38

  1. PROC MEANS DATA=ORGANIZATION MEAN SUM MAXDEC=2; VAR TOTREV; run;

  2. PROC MEANS DATA=ORGANIZATION MAXDEC=2; VAR TOTREV; run;

  3. PROC MEANS DATA=ORGANIZATION MEAN SUM MAXDEC=2; run;

  4. PROC MEANS DATA=ORGANIZATION SUM ; VAR TOTREV; run;


Correct Option: A

There are 45 records having the variable REGION value as missing.How to display the SUM and MEAN of TOTREV for these records?

  1. PROC MEANS DATA= ORGANIZATION SUM MEAN ; CLASS REGION; VAR TOTREV / MISSING; run;

  2. PROC MEANS DATA= ORGANIZATION SUM MEAN MAXDEC=0 NMISS; CLASS REGION; VAR TOTREV; run;

  3. PROC MEANS DATA= ORGANIZATION SUM MEAN MAXDEC=0 if not MISSING; CLASS REGION; VAR TOTREV; run;

  4. PROC MEANS DATA= ORGANIZATION SUM MEAN MAXDEC=0 MISSING; CLASS REGION; VAR TOTREV; run;


Correct Option: D

How to obtain only the MEAN and SUM of TOTREV classified by REGION in the ORGANIZATION data set.

  1. PROC MEANS DATA= ORGANIZATION ; CLASS REGION; VAR TOTREV ; run;

  2. PROC MEANS DATA= ORGANIZATION SUM MEAN MAXDEC=0 ; CLASS REGION; VAR TOTREV ; run;

  3. PROC MEANS DATA= ORGANIZATION SUM MEAN MAXDEC=0 ; BY REGION; CLASS TOTREV ; run;

  4. PROC MEANS DATA= ORGANIZATION SUM MEAN MAXDEC=0 ; CLASS North_Region; VAR TOTREV ; run;


Correct Option: B

What does the following code do? PROC MEANS DATA= ORGANIZATION(WHERE=(REGION IN('WESTERN','SOUTHERN') and SUBSTR(RATE_SCHEDULE,1,2) = 'E1')) MAXDEC = 0 MEAN SUM NONOBS; VAR TOTREV; CLASS REGION RATE_SCHEDULE; run;

  1. Calculate the mean total revenue classified by REGION and RATE_SCHEDULE, but only for the WESTERN and SOUTHERN REGIONS, and only for those two regions whose values of RATE_SCHEDULE start with the string “E1.”

  2. Displays the number of observations(records), mean and total revenue classified by REGION and RATE_SCHEDULE, for the WESTERN and SOUTHERN REGIONS, and only for those two regions whose values of RATE_SCHEDULE start with the string “E1.”

  3. Calculate the mean total revenue classified by REGION and RATE_SCHEDULE, for all the regions except the WESTERN and SOUTHERN REGIONS, and only for those two regions whose values of RATE_SCHEDULE start with the string “E1.”

  4. Displays the Rate Schedule of the WESTERN and SOUTHERN REGIONS where variable TOTREV is an integer.


Correct Option: A

data test; input region $ totrev tothrs totkwh; datalines; north 3 45 55 north 345 64 64 south 235 34 345 east 23 346 576 south 23 5 4 ; run; PROC MEANS DATA=TEST1 NOPRINT; VAR TOTREV TOTKWH TOTHRS; OUTPUT OUT=TEST2 sum(TOTREV TOTKWH) = mean(TOTREV) = median(TOTHRS) = / AUTONAME; run; What are the column names of the dataset TEST2?

  1. TYPE , FREQ , totrev_Sum , totkwh_Sum , totrev_Mean , tothrs_Median

  2. TYPE , FREQ , total revenue sum , total kwh Sum , total revenue Mean , total hrs Median

  3. TYPE , FREQ , totrev , totkwh , tothrs

  4. totrev_Sum , totkwh_Sum , totrev_Mean , tothrs_Median


Correct Option: A

Which of the following code can obtain a 95 percent confidence interval around the mean total KwH consumption and around the mean billed revenue, along with the mean and median from the dataset ORGANIZATION.

  1. PROC MEANS DATA= ORGANIZATION MEDIAN MEAN CLM MAXDEC=0; Label TOTREV = 'Total Billed Revenue' TOTKWH = 'Total KwH Consumption'; VAR TOTREV TOTKWH; run;

  2. PROC MEANS DATA= ORGANIZATION MEDIAN MEAN UCLM ; Label TOTREV = 'Total Billed Revenue' TOTKWH = 'Total KwH Consumption'; VAR TOTREV TOTKWH; run;

  3. PROC MEANS DATA= ORGANIZATION MEDIAN MEAN LCLM Label TOTREV = 'Total Billed Revenue' TOTKWH = 'Total KwH Consumption'; VAR TOTREV TOTKWH; run;

  4. PROC MEANS DATA= ORGANIZATION MEDIAN SUM CLM MAXDEC=0; Label TOTREV = 'Total Billed Revenue' TOTKWH = 'Total KwH Consumption'; VAR TOTREV TOTKWH; run;


Correct Option: A

A variable defined in a report is available

  1. For one tab

  2. For all tabs of the Report

  3. Depends how it is defined as global or Private

  4. None of the above


Correct Option: B

Suppose you want to define a class named Application1. This is the only class in the application. Which code completes the declaration of the class?

  1. class Application1

  2. public class Application1

  3. public static void Application1

  4. static Application1


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) class Application1 - This option is incorrect because it only declares the class without specifying any access modifiers.

Option B) public class Application1 - This option is correct because it declares the class with the "public" access modifier, which means the class can be accessed from other parts of the application.

Option C) public static void Application1 - This option is incorrect because it declares a method named "Application1" with the "public" and "static" access modifiers, but it does not declare a class.

Option D) static Application1 - This option is incorrect because it does not specify any access modifiers for the class declaration.

The correct answer is Option B) public class Application1. This option is correct because it declares the class with the "public" access modifier, allowing the class to be accessed from other parts of the application.

Suppose you are using a Windows operating system and you wish to run an application. The application class is named App1 and is contained within the samples.java package. Choose the command that will run the application.

  1. java App1.samples.java

  2. java samples.java.App1

  3. javac samples.java.App1

  4. javac App1.samples.java


Correct Option: B
Explanation:

To run an application in Java, the user needs to know the correct command to execute. In this case, we are given the class name and package name of the application we wish to run.

Option A: java App1.samples.java - This option is incorrect because it uses an invalid syntax to run the application. The correct format is "java .".

Option B: java samples.java.App1 - This option is correct. By specifying the full package and class name, we can run the application using the Java Virtual Machine (JVM).

Option C: javac samples.java.App1 - This option is incorrect because the "javac" command is used to compile Java source code, not run an application.

Option D: javac App1.samples.java - This option is incorrect because it uses an invalid syntax to compile the application. The correct format is "javac /.java".

Therefore, the correct answer is:

The Answer is: B

Suppose you want to declare an array of the first five letters of the alphabet. How do you declare and initialize the array?

  1. char[] alpha = {'A', 'B', 'C', 'D', 'E'};

  2. char[] alpha = {"A", "B", "C", "D", "E"};

  3. char[] alpha = new char('A', 'B', 'C', 'D', 'E');

  4. char[][] alpha = {{'A', 'B', 'C', 'D', 'E'}};


Correct Option: A
Explanation:

To solve this question, the user needs to know how to declare and initialize an array in Java.

Option A is correct since it declares an array of characters and initializes it with the given values separated by commas within curly braces. This is the correct syntax for initializing a character array in Java.

Option B is incorrect because it uses double quotes (") instead of single quotes (') to initialize the characters. In Java, double quotes are used for Strings while single quotes are used for characters.

Option C is incorrect because the syntax for initializing an array using the "new" keyword is incorrect. The correct syntax is to use square brackets after the data type to specify the size of the array.

Option D is incorrect because it declares a two-dimensional array instead of a one-dimensional array. The inner curly braces are not needed since there is only one dimension.

Therefore, the correct answer is:

The Answer is: A. char[] alpha = {'A', 'B', 'C', 'D', 'E'};

Which range of values is valid for all integral types, where n is the number of bits?

  1. 2^(n-1) to 2^(n+1)+1

  2. -2^(n-1) to 2^(n-1)-1

  3. -2^(n-1) to 2^(n-1)+1

  4. -2^(n-1) to 2^(n+1)-1


Correct Option: B

AI Explanation

To answer this question, you need to understand the range of values that can be represented by integral types.

Integral types include signed and unsigned integers. The range of values for signed integers depends on the number of bits used to represent them.

For a signed integer with n bits, the range of values that can be represented is from -2^(n-1) to 2^(n-1)-1. This means that the most significant bit is used to represent the sign of the number (0 for positive, 1 for negative), and the remaining n-1 bits are used to represent the magnitude of the number.

Let's go through each option to understand why it is correct or incorrect:

Option A) 2^(n-1) to 2^(n+1)+1 - This option is incorrect because it includes values outside the valid range for signed integers.

Option B) -2^(n-1) to 2^(n-1)-1 - This option is correct. It represents the valid range for signed integers, where the most significant bit represents the sign bit.

Option C) -2^(n-1) to 2^(n-1)+1 - This option is incorrect because it includes an extra value (2^(n-1)+1) outside the valid range for signed integers.

Option D) -2^(n-1) to 2^(n+1)-1 - This option is incorrect because it includes values outside the valid range for signed integers.

Therefore, the correct answer is B. The range of values that is valid for all integral types, where n is the number of bits, is -2^(n-1) to 2^(n-1)-1.

Which lexical elements do you use to start and end a comment that you wish to include as part of documentation? Choose more than one option.

  1. //

  2. /*

  3. /**

  4. */


Correct Option: C,D

AI Explanation

To include comments as part of documentation, you typically use specific lexical elements to indicate the start and end of the comment. In this case, you have to choose more than one option from the given choices.

Let's go through each option to understand why it is correct or incorrect:

Option A) // - This option is incorrect because double forward slashes (//) are typically used to start a single-line comment in many programming languages, but they are not commonly used to indicate comments in documentation.

Option B) /* - This option is incorrect because a forward slash followed by an asterisk (/*) is commonly used to start a multi-line comment in many programming languages, but it is not a common choice for documenting comments.

Option C) /** - This option is correct because a forward slash followed by two asterisks (/**) is commonly used to start a comment block in documentation. This is often used in conjunction with a specific format called a "docstring" to document code.

Option D) / - This option is correct because an asterisk followed by a forward slash (/) is commonly used to end a comment block in documentation. This is the closing element that matches the opening /**.

Therefore, the correct answers are Option C (/*) and Option D (/). These options are correct because they are commonly used to start and end comment blocks in documentation.

Assume you have created a piece of Java source code and compiled it successfully. How does the Java platform execute the code?

  1. The compiler interprets the bytecode in the Java class file

  2. The Java Virtual Machine (JVM) interprets the bytecode in the Java class file

  3. The JVM interprets the native machine code

  4. The JVM translates compiled bytecode to machine code


Correct Option: B,D

You are required to represent the employees at a company in Java code. The employees are categorized according to their position and salary. You also need to be able to change the state of an employee due to a promotion. How could you represent this?

  1. Create a Salary object

  2. Declare an Employee class

  3. Declare an instance of the Employee class called Promotion

  4. Declare a promotion method that changes the value of the position variable

  5. Define variables for position and salary


Correct Option: B,D

Which Java keywords do you use in conditional statements to control program flow? Choose more than one option.

  1. catch

  2. else

  3. finally

  4. if


Correct Option: B,D

Identify the type of the following comment: /* this method prints out all *the employee's information */ Choose an option.

  1. Doc comment

  2. In-line comment

  3. Multi-line comment

  4. none


Correct Option: C

What is the correct way to declare and initialize a string object, "start", whose value - "Welcome to Java Programming" - can be shared?

  1. String start = new String("Welcome to Java Programming");

  2. String start[] = "Welcome to Java Programming";

  3. String start = "Welcome to Java Programming";

  4. none


Correct Option: C

When do you need to use an array?

  1. To create a mutable string

  2. To store a single character

  3. To store multiple items of the same type

  4. none


Correct Option: C

Assume you create a Student class with the variables name, ID, and course. You then create a method called gradeStudent. If you create a subclass of the Student class called GraduateStudent, what does it inherit?

  1. An instance of the Student class

  2. The course variable

  3. The gradeStudent method

  4. The ID variable

  5. The name variable


Correct Option: B,C,D,E
- Hide questions