Class 10 2024-2025 Wrapper Classes PDF

Document Details

LegendaryRockCrystal5377

Uploaded by LegendaryRockCrystal5377

Nasr School

Ruchi Gupta Badhwar

Tags

wrapper classes java programming computer applications programming

Summary

This document is a set of class notes on wrapper classes in Java programming. It includes example code & practice questions, covering concepts from different perspectives. The file covers basics about wrapper classes like "Byte", "Short", "Integer", etc, and their usage.

Full Transcript

COMPUTER APPLICATIONS Class X CLASS 10 2024-25 File 7 - Wrapper Classes  A wrapper class acts as a wrapper around a primitive datatype so that it can be treated as a class.  Each primitive datatype has its ow...

COMPUTER APPLICATIONS Class X CLASS 10 2024-25 File 7 - Wrapper Classes  A wrapper class acts as a wrapper around a primitive datatype so that it can be treated as a class.  Each primitive datatype has its own wrapper class.  All wrapper classes are present in java.lang package. S.No. Primitive Datatype Wrapper Class S.No. Primitive Datatype Wrapper Class 1. byte Byte 5. float Float 2. short Short 6. double Double 3. int Integer 7. char Character 4. long Long 8. boolean Boolean Uses: There are many uses of wrapper classes. 1) By using wrapper class functions, primitive types can be converted to their respective object types and vice- versa. Eg: int can be converted to Integer and vice-versa is also true. 2) They can be used to convert string values to numbers. 3) Any numeric datatype can be converted to a string value. 4) A wrapper class can be used to determine the nature of data. Eg: If a character is taken as input, we can use Character wrapper class functions to determine whether it is a letter or a digit or a special character. According to your board portion, you need to learn only those functions that are mentioned in this file. Character Wrapper Class  To use any of the functions of the Character wrapper class, write Character.functionname(). This can be done only because they are static functions of the Character class.  All the functions take a char value as a parameter.  The first 6 functions return a boolean value.  The last 2 functions return a char value. Type of Return type or S.No. Name Description parameter Type of result 1. Character.isUpperCase() char boolean Returns true only if the character is in uppercase. 2. Character.isLowerCase() char boolean Returns true only if the character is in lowercase. 3. Character.isDigit() char boolean Returns true only if the character is a digit 4. Character.isLetter() char boolean Returns true only if the character is a letter (uppercase or lowercase). 5. Character.isLetterOrDigit() char boolean Returns true only if the character is a letter or a digit (uppercase or lowercase or 0-9). 6. Character.isWhitespace() char boolean Returns true if the given character is a whitespace (\n, \t and space) 7. Character.toUpperCase() char char Returns the given character in uppercase only if it is in lowercase. Otherwise, the same character is returned. 8. Character.toLowerCase() char char Returns the given character in lowercase only if it is in uppercase. Otherwise, the same character is returned. Page 1 of 5 CLASS 10 2024-25 File 7 - Wrapper Classes – By Ruchi Gupta Badhwar WORKING ON CHARACTERS Suppose that c is a character (char variable) to be checked. Three ways to check for uppercase letter: Three ways to check for lowercase letter:  if(c>=65 && c=97 && c=’A’ && c=’a’ && c=65&&c=97&& c=48 && c=’A’ && c=’a’ && c=’0’ && c=65&&c=97&& c=48 && c=’A’ && c=’a’ && c=’0’ && c=65 && c=97 && c=48 && c=65 && c=97 && c

Use Quizgecko on...
Browser
Browser