SlideShare a Scribd company logo
1 of 2
Download to read offline
Java programming questions
1. Why do we instantiate an object of a class?
2. What object can you use to read data into a Java program?
3. What method can you use to display formatted information?
4. What method is used to output some text and then go to the next line?
5. “Scanner” is part of what package?
6. Write a statement that creates a Scanner object called MyInput that reads from the keyboard.
7. Name two Scanner method (hint: one that reads a word and one that reads a line)
8. What is a driver/client program?
9. Why the data items in a class are called instance variables?
10. Why instance variables are declared private? And how do we modify (read/write) them?
Solution
1. Why do we instantiate an object of a class?
Instantiating an object of a class means allocating the required memory for the object, and
assigning some possible values to those object members is what instantiation is.
2. What object can you use to read data into a Java program?
There are multiple possible objects that can be used to read data into a Java program. Scanner
object is the easiest which reads data from the console.
3. What method can you use to display formatted information?
Again there are multiple possible methods. Where as to display formatted information, the well
known method is: System.out.format().
4. What method is used to output some text and then go to the next line?
To print some text to the screen, and move to the next line, the method used is:
System.out.println(); Here ln stands for line(new line.)
5. “Scanner” is part of what package?
Scanner is part of java.util.* package.
6. Write a statement that creates a Scanner object called MyInput that reads from the keyboard.
Scanner MyInput = new Scanner(System.in) will read data from keyboard.
7. Name two Scanner method (hint: one that reads a word and one that reads a line)
The two Scanner methods are: Scanner.next() which reads the next word, and
Scanner.nextLine() which reads the next line of data.
8. What is a driver/client program?
9. Why the data items in a class are called instance variables?
10. Why instance variables are declared private? And how do we modify (read/write) them?

More Related Content

Similar to Java programming questions1. Why do we instantiate an object of a .pdf

MC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionMC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionNarinder Kumar
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manualLaura Popovici
 
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
IRJET -  	  Cognitive based Emotion Analysis of a Child Reading a BookIRJET -  	  Cognitive based Emotion Analysis of a Child Reading a Book
IRJET - Cognitive based Emotion Analysis of a Child Reading a BookIRJET Journal
 
Mit103 object oriented programming
Mit103  object oriented programmingMit103  object oriented programming
Mit103 object oriented programmingsmumbahelp
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answersKrishnaov
 
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSULTHAN BASHA
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkAkhil Mittal
 
Example Of Import Java
Example Of Import JavaExample Of Import Java
Example Of Import JavaMelody Rios
 
Car Showroom management System in c++
Car Showroom management System in c++Car Showroom management System in c++
Car Showroom management System in c++PUBLIVE
 
Top 20 Asp.net interview Question and answers
Top 20 Asp.net interview Question and answersTop 20 Asp.net interview Question and answers
Top 20 Asp.net interview Question and answersw3asp dotnet
 
Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02Hardeep Kaur
 
Core Java Interview Questions with Answers.pdf
Core Java Interview Questions with Answers.pdfCore Java Interview Questions with Answers.pdf
Core Java Interview Questions with Answers.pdfSudhanshiBakre1
 
C# classes
C#   classesC#   classes
C# classesTiago
 

Similar to Java programming questions1. Why do we instantiate an object of a .pdf (20)

MC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionMC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall session
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manual
 
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
IRJET -  	  Cognitive based Emotion Analysis of a Child Reading a BookIRJET -  	  Cognitive based Emotion Analysis of a Child Reading a Book
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
 
Java basic concept
Java basic conceptJava basic concept
Java basic concept
 
Java
JavaJava
Java
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
Railway Route Optimizer
Railway Route OptimizerRailway Route Optimizer
Railway Route Optimizer
 
Mit103 object oriented programming
Mit103  object oriented programmingMit103  object oriented programming
Mit103 object oriented programming
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity Framework
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Example Of Import Java
Example Of Import JavaExample Of Import Java
Example Of Import Java
 
Car Showroom management System in c++
Car Showroom management System in c++Car Showroom management System in c++
Car Showroom management System in c++
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
 
A44090104
A44090104A44090104
A44090104
 
Top 20 Asp.net interview Question and answers
Top 20 Asp.net interview Question and answersTop 20 Asp.net interview Question and answers
Top 20 Asp.net interview Question and answers
 
Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02
 
Core Java Interview Questions with Answers.pdf
Core Java Interview Questions with Answers.pdfCore Java Interview Questions with Answers.pdf
Core Java Interview Questions with Answers.pdf
 
C# classes
C#   classesC#   classes
C# classes
 

More from arrowmobile

ESSAY QUESTIONS - ETHICSLewis Archer is an outside auditor who dis.pdf
ESSAY QUESTIONS - ETHICSLewis Archer is an outside auditor who dis.pdfESSAY QUESTIONS - ETHICSLewis Archer is an outside auditor who dis.pdf
ESSAY QUESTIONS - ETHICSLewis Archer is an outside auditor who dis.pdfarrowmobile
 
Determine whether each of following statements is true or false. Prov.pdf
Determine whether each of following statements is true or false. Prov.pdfDetermine whether each of following statements is true or false. Prov.pdf
Determine whether each of following statements is true or false. Prov.pdfarrowmobile
 
describe the oceans solubility pump and the oceans biological pump u.pdf
describe the oceans solubility pump and the oceans biological pump u.pdfdescribe the oceans solubility pump and the oceans biological pump u.pdf
describe the oceans solubility pump and the oceans biological pump u.pdfarrowmobile
 
Describe how bacterial cells compare to onion cells.SolutionPl.pdf
Describe how bacterial cells compare to onion cells.SolutionPl.pdfDescribe how bacterial cells compare to onion cells.SolutionPl.pdf
Describe how bacterial cells compare to onion cells.SolutionPl.pdfarrowmobile
 
A facility is to be designed with 7 departments (Dl-D7) such that the.pdf
A facility is to be designed with 7 departments (Dl-D7) such that the.pdfA facility is to be designed with 7 departments (Dl-D7) such that the.pdf
A facility is to be designed with 7 departments (Dl-D7) such that the.pdfarrowmobile
 
Briefly discuss each of the chronological steps in the process o.pdf
Briefly discuss each of the chronological steps in the process o.pdfBriefly discuss each of the chronological steps in the process o.pdf
Briefly discuss each of the chronological steps in the process o.pdfarrowmobile
 
Which protocol uses tunneling to send PPP packets over a nonsecure n.pdf
Which protocol uses tunneling to send PPP packets over a nonsecure n.pdfWhich protocol uses tunneling to send PPP packets over a nonsecure n.pdf
Which protocol uses tunneling to send PPP packets over a nonsecure n.pdfarrowmobile
 
What is the simple formula for figuring Addition to Retained earn.pdf
What is the simple formula for figuring Addition to Retained earn.pdfWhat is the simple formula for figuring Addition to Retained earn.pdf
What is the simple formula for figuring Addition to Retained earn.pdfarrowmobile
 
Why can we not see individual photons, but rather light appear to us.pdf
Why can we not see individual photons, but rather light appear to us.pdfWhy can we not see individual photons, but rather light appear to us.pdf
Why can we not see individual photons, but rather light appear to us.pdfarrowmobile
 
Why is it important to study reactions norms to understand phenotypi.pdf
Why is it important to study reactions norms to understand phenotypi.pdfWhy is it important to study reactions norms to understand phenotypi.pdf
Why is it important to study reactions norms to understand phenotypi.pdfarrowmobile
 
Which of the following is true about the nucleolusA)found in prok.pdf
Which of the following is true about the nucleolusA)found in prok.pdfWhich of the following is true about the nucleolusA)found in prok.pdf
Which of the following is true about the nucleolusA)found in prok.pdfarrowmobile
 
1. The gene OCA2 on chromosome 15 confers eye color in humans. The m.pdf
1. The gene OCA2 on chromosome 15 confers eye color in humans. The m.pdf1. The gene OCA2 on chromosome 15 confers eye color in humans. The m.pdf
1. The gene OCA2 on chromosome 15 confers eye color in humans. The m.pdfarrowmobile
 
The graph of a periodic function is given below.- Define a functio.pdf
The graph of a periodic function is given below.- Define a functio.pdfThe graph of a periodic function is given below.- Define a functio.pdf
The graph of a periodic function is given below.- Define a functio.pdfarrowmobile
 
What is the three point notationSolutionIn a 3D Cartesian coo.pdf
What is the three point notationSolutionIn a 3D Cartesian coo.pdfWhat is the three point notationSolutionIn a 3D Cartesian coo.pdf
What is the three point notationSolutionIn a 3D Cartesian coo.pdfarrowmobile
 
What is SOPA Discuss SOPA development and enforcement.Solution.pdf
What is SOPA Discuss SOPA development and enforcement.Solution.pdfWhat is SOPA Discuss SOPA development and enforcement.Solution.pdf
What is SOPA Discuss SOPA development and enforcement.Solution.pdfarrowmobile
 
Walking through the forest you come to a dry creek bed, and notice t.pdf
Walking through the forest you come to a dry creek bed, and notice t.pdfWalking through the forest you come to a dry creek bed, and notice t.pdf
Walking through the forest you come to a dry creek bed, and notice t.pdfarrowmobile
 
What does decrease in water potential mean (Lower negative value.pdf
What does decrease in water potential mean (Lower negative value.pdfWhat does decrease in water potential mean (Lower negative value.pdf
What does decrease in water potential mean (Lower negative value.pdfarrowmobile
 
Understand and describe the following technologies Flow Cytometry, .pdf
Understand and describe the following technologies Flow Cytometry, .pdfUnderstand and describe the following technologies Flow Cytometry, .pdf
Understand and describe the following technologies Flow Cytometry, .pdfarrowmobile
 
1. What would determine protein levels in cells2.Draw a hypotheti.pdf
1. What would determine protein levels in cells2.Draw a hypotheti.pdf1. What would determine protein levels in cells2.Draw a hypotheti.pdf
1. What would determine protein levels in cells2.Draw a hypotheti.pdfarrowmobile
 
Tversky and Kahneman1 asked a group of subjects to carry out the fol.pdf
Tversky and Kahneman1 asked a group of subjects to carry out the fol.pdfTversky and Kahneman1 asked a group of subjects to carry out the fol.pdf
Tversky and Kahneman1 asked a group of subjects to carry out the fol.pdfarrowmobile
 

More from arrowmobile (20)

ESSAY QUESTIONS - ETHICSLewis Archer is an outside auditor who dis.pdf
ESSAY QUESTIONS - ETHICSLewis Archer is an outside auditor who dis.pdfESSAY QUESTIONS - ETHICSLewis Archer is an outside auditor who dis.pdf
ESSAY QUESTIONS - ETHICSLewis Archer is an outside auditor who dis.pdf
 
Determine whether each of following statements is true or false. Prov.pdf
Determine whether each of following statements is true or false. Prov.pdfDetermine whether each of following statements is true or false. Prov.pdf
Determine whether each of following statements is true or false. Prov.pdf
 
describe the oceans solubility pump and the oceans biological pump u.pdf
describe the oceans solubility pump and the oceans biological pump u.pdfdescribe the oceans solubility pump and the oceans biological pump u.pdf
describe the oceans solubility pump and the oceans biological pump u.pdf
 
Describe how bacterial cells compare to onion cells.SolutionPl.pdf
Describe how bacterial cells compare to onion cells.SolutionPl.pdfDescribe how bacterial cells compare to onion cells.SolutionPl.pdf
Describe how bacterial cells compare to onion cells.SolutionPl.pdf
 
A facility is to be designed with 7 departments (Dl-D7) such that the.pdf
A facility is to be designed with 7 departments (Dl-D7) such that the.pdfA facility is to be designed with 7 departments (Dl-D7) such that the.pdf
A facility is to be designed with 7 departments (Dl-D7) such that the.pdf
 
Briefly discuss each of the chronological steps in the process o.pdf
Briefly discuss each of the chronological steps in the process o.pdfBriefly discuss each of the chronological steps in the process o.pdf
Briefly discuss each of the chronological steps in the process o.pdf
 
Which protocol uses tunneling to send PPP packets over a nonsecure n.pdf
Which protocol uses tunneling to send PPP packets over a nonsecure n.pdfWhich protocol uses tunneling to send PPP packets over a nonsecure n.pdf
Which protocol uses tunneling to send PPP packets over a nonsecure n.pdf
 
What is the simple formula for figuring Addition to Retained earn.pdf
What is the simple formula for figuring Addition to Retained earn.pdfWhat is the simple formula for figuring Addition to Retained earn.pdf
What is the simple formula for figuring Addition to Retained earn.pdf
 
Why can we not see individual photons, but rather light appear to us.pdf
Why can we not see individual photons, but rather light appear to us.pdfWhy can we not see individual photons, but rather light appear to us.pdf
Why can we not see individual photons, but rather light appear to us.pdf
 
Why is it important to study reactions norms to understand phenotypi.pdf
Why is it important to study reactions norms to understand phenotypi.pdfWhy is it important to study reactions norms to understand phenotypi.pdf
Why is it important to study reactions norms to understand phenotypi.pdf
 
Which of the following is true about the nucleolusA)found in prok.pdf
Which of the following is true about the nucleolusA)found in prok.pdfWhich of the following is true about the nucleolusA)found in prok.pdf
Which of the following is true about the nucleolusA)found in prok.pdf
 
1. The gene OCA2 on chromosome 15 confers eye color in humans. The m.pdf
1. The gene OCA2 on chromosome 15 confers eye color in humans. The m.pdf1. The gene OCA2 on chromosome 15 confers eye color in humans. The m.pdf
1. The gene OCA2 on chromosome 15 confers eye color in humans. The m.pdf
 
The graph of a periodic function is given below.- Define a functio.pdf
The graph of a periodic function is given below.- Define a functio.pdfThe graph of a periodic function is given below.- Define a functio.pdf
The graph of a periodic function is given below.- Define a functio.pdf
 
What is the three point notationSolutionIn a 3D Cartesian coo.pdf
What is the three point notationSolutionIn a 3D Cartesian coo.pdfWhat is the three point notationSolutionIn a 3D Cartesian coo.pdf
What is the three point notationSolutionIn a 3D Cartesian coo.pdf
 
What is SOPA Discuss SOPA development and enforcement.Solution.pdf
What is SOPA Discuss SOPA development and enforcement.Solution.pdfWhat is SOPA Discuss SOPA development and enforcement.Solution.pdf
What is SOPA Discuss SOPA development and enforcement.Solution.pdf
 
Walking through the forest you come to a dry creek bed, and notice t.pdf
Walking through the forest you come to a dry creek bed, and notice t.pdfWalking through the forest you come to a dry creek bed, and notice t.pdf
Walking through the forest you come to a dry creek bed, and notice t.pdf
 
What does decrease in water potential mean (Lower negative value.pdf
What does decrease in water potential mean (Lower negative value.pdfWhat does decrease in water potential mean (Lower negative value.pdf
What does decrease in water potential mean (Lower negative value.pdf
 
Understand and describe the following technologies Flow Cytometry, .pdf
Understand and describe the following technologies Flow Cytometry, .pdfUnderstand and describe the following technologies Flow Cytometry, .pdf
Understand and describe the following technologies Flow Cytometry, .pdf
 
1. What would determine protein levels in cells2.Draw a hypotheti.pdf
1. What would determine protein levels in cells2.Draw a hypotheti.pdf1. What would determine protein levels in cells2.Draw a hypotheti.pdf
1. What would determine protein levels in cells2.Draw a hypotheti.pdf
 
Tversky and Kahneman1 asked a group of subjects to carry out the fol.pdf
Tversky and Kahneman1 asked a group of subjects to carry out the fol.pdfTversky and Kahneman1 asked a group of subjects to carry out the fol.pdf
Tversky and Kahneman1 asked a group of subjects to carry out the fol.pdf
 

Recently uploaded

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Recently uploaded (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

Java programming questions1. Why do we instantiate an object of a .pdf

  • 1. Java programming questions 1. Why do we instantiate an object of a class? 2. What object can you use to read data into a Java program? 3. What method can you use to display formatted information? 4. What method is used to output some text and then go to the next line? 5. “Scanner” is part of what package? 6. Write a statement that creates a Scanner object called MyInput that reads from the keyboard. 7. Name two Scanner method (hint: one that reads a word and one that reads a line) 8. What is a driver/client program? 9. Why the data items in a class are called instance variables? 10. Why instance variables are declared private? And how do we modify (read/write) them? Solution 1. Why do we instantiate an object of a class? Instantiating an object of a class means allocating the required memory for the object, and assigning some possible values to those object members is what instantiation is. 2. What object can you use to read data into a Java program? There are multiple possible objects that can be used to read data into a Java program. Scanner object is the easiest which reads data from the console. 3. What method can you use to display formatted information? Again there are multiple possible methods. Where as to display formatted information, the well known method is: System.out.format(). 4. What method is used to output some text and then go to the next line? To print some text to the screen, and move to the next line, the method used is: System.out.println(); Here ln stands for line(new line.) 5. “Scanner” is part of what package? Scanner is part of java.util.* package. 6. Write a statement that creates a Scanner object called MyInput that reads from the keyboard. Scanner MyInput = new Scanner(System.in) will read data from keyboard. 7. Name two Scanner method (hint: one that reads a word and one that reads a line) The two Scanner methods are: Scanner.next() which reads the next word, and Scanner.nextLine() which reads the next line of data. 8. What is a driver/client program? 9. Why the data items in a class are called instance variables?
  • 2. 10. Why instance variables are declared private? And how do we modify (read/write) them?