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







Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.