• Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Have any question?

(+91) 98222 16647
info@simplycoding.in
RegisterLogin
Simply Coding
  • Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Introduction to Java

Input/Output in Java

  • Categories Introduction to Java, Math Library, Java

Q.1 What is a stream?
Ans.    

  • A stream is an abstraction that brings in or sends data.
  • Stream is actually a sequence of data.
  • Streams are one way either input or output.
  • Streams are typically connected to a data source, or data destination, like a file, network connection etc.

Q.2 Which stream is opened automatically by java?
Ans.
There are three streams connected with console that are opened automatically for us:

  • System.out: standard output stream (Console by default)
  • System.in: standard input stream (Keyboard by default)
  • System.err: standard error stream (Console by default)

Q. 3  What is java scanner class?
Ans. Java Scanner class comes under the java.util package. The Java Scanner class breaks the input into tokens using a delimiter that is whitespace by default. It provides many methods to read and parse various primitive values. Java Scanner class is widely used to parse text for string and primitive

Q. 4 What are the different methods to read from Java scanner class?
Ans.

MethodDescription
nextBoolean()Reads a boolean value from the user
nextByte()Reads a byte value from the user
nextDouble()Reads a double value from the user
nextFloat()Reads a float value from the user
nextInt()Reads a int value from the user
nextLine()Reads a String value from the user
Next()Reads a String value from the user (till first space)
nextLong()Reads a long value from the user
nextShort()Reads a short value from the user

Q. 5 How do you read a character as input from user?
Ans. We read in a character by reading a string and then using charAt() method to extract  first character from it.
So the command is: next().charAt(0);

Q. 6 What is difference between next and nextLine?
Ans.

next()nextLine()
Finds and returns the next complete token from this scanner.nextLine() reads input including space between the words i.e. it reads till the end of line
Can read the input only till the space.Can read spaces
It places the cursor in the same line after reading the input.Once the input is read, nextLine() positions the cursor in the next line.

Q. 7 What is bufferedreader class in Java?
Ans. BufferedReader is Java class to reads the text from an Input stream (like a file) by buffering characters that seamlessly reads characters, arrays or lines. In general, each read request made of a Reader causes a corresponding read request to be made of the underlying character or byte stream. It improves the performance by buffering the input.

  • Share:
author avatar
Simply Coding

Previous post

Emerging Technologies - Question and Answers
January 17, 2021

Next post

Important Java Single Dimensional Array Programs
February 17, 2021

You may also like

Questions on Encapsulation
Questions on Encapsulation
4 July, 2021
Questions on Library classes
Questions on Library classes
4 July, 2021
Questions on String 1
What is Java String?
3 July, 2021

Leave A Reply Cancel reply

You must be logged in to post a comment.

Categories

  • Uncategorized
  • Programs
    • Python
    • Java
  • Problems
    • Python
    • Java
    • Web Development
      • Internet
    • Emerging Technologies
  • Notes
    • General
    • QBasic
    • MS Access
    • Web Development
      • XML
      • HTML
      • JavaScript
      • Internet
    • Database
    • Logo Programming
    • Scratch
    • Emerging Trends
      • Artificial Intelligence
      • Internet of Things
      • Cloud Computing
      • Machine Learning
    • Computer Fundamentals
      • Computer Networks
      • E-Services
      • Computer Hardware
    • Python
    • Java
  • School
    • ICSE
      • Computers Class 9
        • Java Introduction
        • Tokens & Data Types
        • Java Operators
        • Math Library
        • if & switch
        • For & While
        • Nested loops
      • Computer Class 10
        • Sample Papers
        • OOPS concepts
        • Functions in Java
        • Constructors
        • Arrays in Java
        • Strings in Java
    • SSC
      • IT Class 11
        • IT Basics
        • DBMS
        • Web Designing
        • Cyber Laws
      • IT Class 12
        • Web Designing
        • SEO
        • Advanced JavaScript
        • Emerging Tech
        • Server Side Scripting
        • E-Com & E-Gov
      • Computer Science 11
      • Computer Science 12
    • CBSE
      • Computer 9
        • Basics of IT
        • Cyber Safety
        • Scratch
        • Python
      • Computer 10
        • Sample Papers
        • Networking
        • HTML
        • Cyber Ethics
        • Scratch
        • Python
      • Computer Science 11
        • Computer Systems
        • Python 11
          • Python Basics
          • Python Tokens
          • Python Operators
          • Python if-else
          • Python loops
          • Python Strings
          • Python List
          • Python Tuple
          • Python Dictionary
          • Python Modules
        • Data Management
      • Computer Science 12
        • Sample Papers
        • Python 12
          • Python Functions
          • Python File Handling
          • Python Libraries
          • Python Recursion
          • Data Structures
        • Computer Networks
        • Data Management
    • ISC
      • Computer Science 11
        • Introduction to Java
        • Values & Data Types
        • Operators
        • if & switch
        • Iterative Statements
        • Functions
        • Arrays
        • String
        • Data Structures
        • Cyber Ethics
      • Computer Science 12
        • Sample Papers
        • Boolean Algebra
        • OOPS
        • Wrapper Classes
        • Functions
        • Arrays
        • String
Simply Coding Computer Courses for School                Privacy Policy     Terms of Use     Contact Us

© 2021 Simply Coding

Login with your site account

Lost your password?

Not a member yet? Register now

Register a new account

Are you a member? Login now