# Java CIS 109 Test 1

14 Questions | Attempts: 299 Settings You will be tested on java constructs such as loops, if conditions, methods etc

• 1.
Which is the correct boolean expression which gives the following meaning:The value of x is greater than 1000 and x is smaller or equal to 2000
• A.

X >= 1000 && x

• B.

X > 1000 && x < 2000

• C.

X < 1000 && x >= 2000

• D.

X > 1000 && x

• E.

None of the above

• 2.
Will this compile?class A{    System.out.println(20 * 10);}
• A.

Yes

• B.

No

• 3.
Will this compile?class B{   public static void main(String[] args)   {      Scanner sc = new Scanner(System.in);   }}
• A.

Yes

• B.

No

• 4.
What will this output?System.out.println(5/2);
• A.

2

• B.

2.5

• C.

Some kind of error

• D.

3

• 5.
What will this output?int i = 10;int j = 20;System.out.println("The result of "+j+" division by 2 is "+i+".");
• A.

The result of j division by 2 is i.

• B.

The result of 20 division by 2 is 10.

• C.

The result of10 division by 2 is 20.

• D.

None of the above

• 6.
What will this output?System.out.println(4 + 5 * 2);
• A.

14

• B.

18

• C.

None of the above

• 7.
Rewrite this as a for loopint i = 0;while (i < 10){   System.out.println(i);   i++;}
• 8.
Will the following compile?int i = 0;for (    ; i < 5 ;   ){   System.out.println(i);   i++;}
• A.

Yes

• B.

No

• 9.
What is the return types of the following body of a method{   int i = 10;   return 3 * i;}
• A.

Int

• B.

Long

• C.

Double

• D.

30

• E.

None of the above

• 10.
What is the return types of the following body of a method {    double d = 10;    return 3 * d; }
• A.

Int

• B.

Long

• C.

Double

• D.

30.0

• E.

None of the above

• 11.
What is the return types of the following body of a method {   return "test "+123; }
• A.

Int

• B.

Char

• C.

String

• D.

Test123

• E.

Will not compile

• 12.
What will the following output on the screen?for (int i = 0; i < 5; i++){   System.out.print("*");}
• A.

* * * * *

• B.

*****

• C.

******

• D.

* * * * * *

• E.

None of the above

• 13.
Write a program that will ask the user to start entering numbers. When he enters the number 0, you will show to him the sum of all the numbers he has entered.
• 14.
What will be the output of the following programclass A{   public static void main(String[] args)   {      System.out.println(getWelcomeMessage());   }   static String getWelcomeMessage()   {      return "Welcome!!!";   }}
• A.

GetWelcomeMessage()

• B.

GetWelcomeMessage

• C.

Welcome!!!

• D.

It would give a compilation error

## Related Topics Back to top
×

Wait!
Here's an interesting quiz for you.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7649639,"math_prob":0.83658886,"size":665,"snap":"2022-40-2023-06","text_gpt3_token_len":223,"char_repetition_ratio":0.17246597,"word_repetition_ratio":0.07692308,"special_character_ratio":0.37593985,"punctuation_ratio":0.08695652,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.984481,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-01-31T09:14:26Z\",\"WARC-Record-ID\":\"<urn:uuid:e7564116-cbaa-4cb8-98a6-35db23dc2e8a>\",\"Content-Length\":\"313877\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:378e7ca9-caa3-4e6a-8fee-20eb2530a047>\",\"WARC-Concurrent-To\":\"<urn:uuid:a8423b3e-8bfa-4e95-9be6-a306552e46be>\",\"WARC-IP-Address\":\"104.26.12.111\",\"WARC-Target-URI\":\"https://www.proprofs.com/quiz-school/story.php?title=java-cis-109-test-1\",\"WARC-Payload-Digest\":\"sha1:JY5V5GQ3KF6NDDWAYRXZNJHY6GDRHC6B\",\"WARC-Block-Digest\":\"sha1:LDTAQ3JCG3LIVDKFAYHS3PRWIGN6ELXE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764499857.57_warc_CC-MAIN-20230131091122-20230131121122-00548.warc.gz\"}"}