ADVERTISEMENT
ADVERTISEMENT

Java Scanner Class Aptitude Questions and Answers.
Page 2

List of Java Scanner Class Aptitude Questions

6) Which package should be imported to use Scanner class?
  1. import java.util.System.in;
  2. import java.util.Scanner;
  3. import java.util.System;
  4. import java.util.Input;

7) Consider the given code snippet, What will following code do?
char ch;
Scanner SC=new Scanner (System.in);
ch=SC.nextChar();
  1. Read a single character
  2. Read a string
  3. Read string but store single character
  4. Error

8) What will be printed by following code snippet, if input value is Hello World!?
Scanner scanner = new Scanner(); 
String str; 
str = scanner.next(); 
System.out.print(str); 
  1. Compilation Error
  2. Hello World!
  3. Hello
  4. None of these





ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.