• 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

Short Questions on Package/Wrapper classes

  • Categories Java, Wrapper Classes

 [A1]Add more questions here

Q. 1 Name of the following:

  1. A keyword used to include a package in the program.
  2. Any one reference data types.

Ans.

  1. import
  2. String

Q. 2 Write Java statement as directed:

  1. Assign a integer 123 to an int variable a.
  2. Convert the variable a to a String and store it in the variable s.

Ans.

  1. a. int a=123;
  2. String s=Integer.toString(a);

Q. 3 Answer as directed:

  1. Assign a string “123” to a String variable a.
  2. Convert the variable a to an integer and store it in the variable s.

Ans.

  1. a. String a=”123”;
  2. int s=Integer.parseInt(a);

Q. 4 For the program given below mark the parts ___1___ and __2__ as autoboxing or unboxing.

class Example
{
static void main()
{
Integer i;
int sum=0;
for(i=1;i<=10;i++) //___1___
{
sum=sum+i; //__2__
}
System.out.println(sum);
}
}

Ans.

        __1__:Autoboxing
        __2__:Unboxing

Q. 5 Give the output of the following program when the main( ) method is executed:

class Overload
{
static void wrapper(int a)
{
System.out.println(“int type=”+a);
}
static void wrapper(Integer a)
{
System.out.println(“Integer type=”+a);
}
static void main()
{
int b=13;
Integer c=new Integer(b);
wrapper(c);
wrapper(b);
}
}

Ans. Output:

Integer type=13
int type=13

Q. 6 Give the output of the following code:

String A=“26”, B=“100”;
String D=A+B+“200”;
int x=Integer.parseInt(A);
int y=Integer.parseInt(B);
int d=x+y;
System.out.println(“Result 1=”+D);
System.out.println(“Result 2=”+d);

Ans.
Output:
         Result 1= 26100200
         Result 2=126

Q. 7 Write the return type of the following library functions:

  1. isLetterOrDigit(char)
  2. parseInt()

Ans.

  1. boolean
  2. int

 

Q. 8 (i) int var = ‘A’;       
                   What is the value of var?
         (ii) Name the package that contains wrapper classes.

Ans.

(i) var will hold the ASCII value of ‘A’ which is 65.
(ii) java.lang package contains wrapper classes.

  • Share:
author avatar
Simply Coding

Previous post

If-else and switch Programs
June 22, 2021

Next post

Java Object Oriented Concepts made easy
June 22, 2021

You may also like

Single Linked List Programs in Java
Single Linked List Programs in Java
28 August, 2021
Implementing Stack using Array in Java
Implementing Stack using Array in Java
28 August, 2021
Questions on Library classes
Questions on Library classes
4 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

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