Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 ( 1 0 points ) Which of the following are valid variable declarations: ( Select ALL that are correct ) int a =

Question 1(10 points) Which of the following are valid variable declarations: (Select ALL that are correct) int a=7; long b=-2; char c="Y"; float d=17.2f; double e=9; Java: boolean f=0; C#: bool f=0; Java: boolean g=true; C#: bool g=true;Question 2(10 points) What is the output of the following statements: // Java: String s="Hi"; for(int i=0;i<3;i++){ System.out.print("S"+s); }//C#: string s="Hi"; for(int i=0;i<3;i++){ Console.Write("S"+s); } Hi HiHiHi SHISHISHI SHISHIQuestion 3(10 points) Which of the following blocks of code will successfully ask a user for a number, multiply that number by 2, and print the result Java and C# Code Java C# import java.util.Scanner; System.out.println("Enter a number to be doubled: "); Console.WriteLine("Enter a number to be doubled :"); Scanner myscanner = new Scanner (System.in); string num=Console.ReadLine(); num=2; String num=myscanner. NextLine(); num=2; Console.WriteLine("Your number doubled is "+num) System.out.println("Your number doubled is "+num); Java and C# Code Java C# import java.util.Scanner; Console.WriteLine("Enter a number to be doubled :"); System.out.println("Enter a number to be doubled: "); string answer=Console.ReadLine(); Scanner myscanner = new Scanner (System.in); int num=Int32.Parse (answer); int num=myscanner.nextInt (); num*=2; num=2; Console.WriteLine("Your number doubled is "+num); System.out.println("Your number doubled is "+num); Java and C# Code Java C# import java.util.Scanner; string answer int num; Console.WriteLine("Enter a number to be doubled :"); System.out.println("Enter a number to be doubled: "); Console.ReadLine (answer); scanner myscanner = new Scanner (System.in); int num=Int32.Parse(answer); myscanner.nextInt (num); num=2; num=2; Console.WriteLine("Your number doubled is "+num); System.out.println("Your number doubled is "+num);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

Students also viewed these Databases questions