4. import java.io.InputStreamReader ; import java.io.BufferedReader ; class Application { public static void main ( String [] args ) { System . out . println ( "What is your name?" ); String name = "" ; InputStreamReader input = new InputStreamReader ( System . in ); BufferedReader reader = new BufferedReader ( input ); try { name = reader . readLine (). trim (); } catch ( Exception e ) { ; } System . out . println ( "Nice to meet you, " + name + '!' ); } }
5. puts "What is your name?" name = gets . chomp puts "Nice to meet you, #{ name } !"
6. a = 10 puts 'a is #{a}' puts "a is #{ a } " # output: # a is #{a} # a is 10