• 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

Java

Java character class example questions

  • Categories Java, Wrapper Classes

Q. Write a valid Java statement to convert ch = B’ into small letter and ml = ‘a’ into capital letter forms
Ans.

    1. To convert ch = ‘B’ into small letter the statement is:
      char st= Charaeter.toLowerCase( ch );
    2. To convert ml = „a’ into capital letter the statement is:
      char st= Character.toUpperCase( m1 );

Q. State the output of the following statements after the execution

    1. System.out.println (Character.isLowerCase (‘P’));
    2. System.out.println (Character.isDigit(‘s’));
    3. iii. System.out.println (Character.isUpperCase(‘R’));
    4. System.out.println (Character.isSpaceChar(‘ ‘));

Ans.

    1. False
    2. False
    3. True
    4. True

Q. A character ‘R’ is assigned to a character variable ans. Write valid statements to assign character ‘R’, convert into its ASCII code. Print the character and ASCII code.
Ans.

char ans = „R’; // initializing character R’ to character variable ans
int as = ans; // initializing character variable ‘ans’ to integer variable ‘as’ i.e. stores ASCII
System.out.println(“The character = “+ans +”its ASCII code = ” + as );

Q. Write a valid statement(s) to input a character from input/keyboard using read() method.
Ans.
The character can be input from the keyboard using any of the methods given below:

      1. Char ch= (char)System. in. read();
      2. BufferedReader br= new BufferedReader( new InputStreamReader( System.in);
        char ch= (char) br.read();

Q. State the Output of the following statements after the expression:

    1. System.out.println(Character.isDigit(‘g’));
    2. System.out.println(Character.isUpperCase(‘t’));
    3. System.out.println(Character.isWhitespace(‘\t ‘));
    4. System.out.println(Character.isLowerCase(‘m’));

Ans.

    1. false
    2. false
    3. true
    4. true

Q. Write the output of the following:

(i) System.out.println (Character.isUpperCase(‘D’));
(ii) System.out.println(Character.toUpperCase(‘l’));

Ans.

(i) true
(ii) L

Q. State the method that:

(i) Converts a string to a primitive float data type
(ii) Determines if the specified character is an uppercase character

Ans.

(i) Float.parseFloat()
(ii) Character.isUpperCase()

Q. State the data type and the value of y after the following is executed:

char x =‘5’;
t = Character.isLetter(x);

Ans. t is of boolean type its value is false.

Q. State the data type and value of res after the following is executed:

char ch=‘n’;
res=Character.toUpperCase(ch);

Ans. res is of char type is value is ‘N’.

Q. Write a statement to perform the following task on a string:

    1. Extract the second last character of a word stored in the variable wd.
    2. Cheek if the second character of a string str is in uppercase.

Ans.

    1. char ch = wd.charAt(wt.length() -2);
    2. if (Character.isUpperCase(str.charAt(1))) OR
      if (str.charAt(1)> ‘A ‘ && str.charAt(1) <= ‘z’)

Q. Write a valid Java statement to convert ch = ‘N’ into small letter and ml = ‘d’ into capital letter forms
Ans.

    1. To convert ch = ‘N’ into small letter the statement is:
      char st= Character.toLowerCase( ch );
    2. To convert ml = ‘d’ into capital letter the statement is:
      char st= Character.toUpperCase( m1 );

Q. State the output of the following statements after the execution

    1. System.out.println (Character.isLowerCase (‘A’));
    2. System.out.println (Character.isDigit(‘b’));
    3. System.out.println (Character.isUpperCase(‘T’));
    4. System.out.println (Character.isSpaceChar(‘ ‘));

Ans.

    1. False
    2. False
    3. True
    4. True

Q. Write a valid statement(s) to input a character from input/keyboard using read() method.
Ans. The character can be input from the keyboard using any of the methods given below:

      1. Char ch= (char)System.in.read();
      2. BufferedReader br= new BufferedReader( new InputStreamReader( System.in);
        char ch= (char) br.read();
  • Share:
author avatar
Simply Coding

Previous post

Short questions on Java Functions
June 11, 2020

Next post

Cracking Java String class questions
June 11, 2020

You may also like

Questions on Library classes
Questions on Library classes
4 July, 2021
questions on package-wrapper classes
Short Questions on Package/Wrapper classes
22 June, 2021
Library Classes Programs
Library Classes Programs
19 June, 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

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