variable answer1 might not have been initialized

variable answer1 might not have been initialized

import java .io.*; public class Test{ public static void main(String[] args) throws IOException{ BufferedReader steffi=new BufferedReader(new InputStreamReader(System.in)); String name; String answer1; int ctr1=0;

       System.out.println("Enter your name:");
       name=steffi.readLine();


       System.out.println("1.What is the name of the developer of java?");
       System.out.println("\tA. Steve Jobs");
       System.out.println("\tB. James Gosling");
       System.out.println("\tC. Bill Gates");
       System.out.println("\tD. None of these");
       System.out.print("Enter your answer:");
       if(answer1.equalsIgnoreCase("B"))
       {
        ctr1++;
       }


}

}

View Answers

September 17, 2012 at 11:07 AM

We have modified your code. Here it is:

import java .io.*;
public class Test{
    public static void main(String[] args) throws IOException{ 
        BufferedReader steffi=new BufferedReader(new InputStreamReader(System.in));
        String name; 
        String answer1=""; 
        int ctr1=0;

       System.out.println("Enter your name:");
       name=steffi.readLine();


       System.out.println("1.What is the name of the developer of java?");
       System.out.println("\tA. Steve Jobs");
       System.out.println("\tB. James Gosling");
       System.out.println("\tC. Bill Gates");
       System.out.println("\tD. None of these");
       System.out.print("Enter your answer:");
       answer1=steffi.readLine();
       if(answer1.equalsIgnoreCase("B"))
       {
        ctr1++;
       }

}

}









Related Tutorials/Questions & Answers:
variable answer1 might not have been initialized
variable answer1 might not have been initialized   import java .io...(System.in)); String name; String answer1; int...++; } } }   We have modified your code. Here it is: import java .io
Resources have been modified iPhone
Resources have been modified iPhone  Hi, My client is getting Resources have been modified error while installing AdHoc distribution on his iPhone. How to solve Resources have been modified iPhone error? Thanks   Hi
Advertisements
maximum limit of database connections have been reached.
maximum limit of database connections have been reached.  How do I check in my code whether a maximum limit of database connections have been reached
maximum limit of database connections have been reached.
maximum limit of database connections have been reached.  How do I check in my code whether a maximum limit of database connections have been reached
The app was not installed on iphone because its resources have been modified
The app was not installed on iphone because its resources have been modified  Hi, I am getting following error while my client is installing my... resources have been modified" What is the solution? Thanks   Hi, You have
How to find if you have been hit by Panda 4.0
How to find if you have been hit by Panda 4.0  Hi, This week Google Panda 4.0 is released. Now the question is how to find if your website have been... if your website have been hit by the Panda 4.0. Here are thinks you can do
UI Component initialized
is initialized. 1. preInitialize: is dispatched when the component has been attached... and no children have been created. 2. initialize: is dispatched when a component has finished its construction and its initialization properties have been set
Java variable
Java variable   To what value is a variable of the String type automatically initialized
ModuleNotFoundError: No module named 'mrsn-might'
have to install padas library. You can install mrsn-might python...ModuleNotFoundError: No module named 'mrsn-might'  Hi, My Python... 'mrsn-might' How to remove the ModuleNotFoundError: No module named 'mrsn
What is the purpose of declaring a variable as final?
What is the purpose of declaring a variable as final?   Hi, What is the purpose of declaring a variable as final? Thanks   Hi, In Java when we declare a final variable as a variable which has been initialized
output variable
output variable  if i want to print output of three variables when i wrote the code e.g SYStem.out.PRINTln(answer + answer1 + answer 2) only output of answer is getting printed out? can you help
Creating a Local Variable in JSP
consider a situation where we have to declare a variable as local, then we should...Creating a Local Variable in JSP          In jsp when we have to create a method
Local Variable and Instant Variable
Local Variable and Instant Variable  difference between Local Variable and Instant Variable   Difference between local variable and instance variable Instance variable is declared within a class but not within
You have been working with this current firm for a long time. Don?t you think it would be difficult now to switch over t
You have been working with this current firm for a long time. Don’t... the needs of the position in question are similar to the work you have been doing so.... The best way to tackle this is to show how you have had many changing scenarios within
if variable is null php
if variable is null php  How to check if submitted variable is null in PHP? Thanks!   Check if Variable is NULL in PHP... if the variable is not defined or null in PHP. and after setting a variable
Protecting Your iPad Has Never Been Easier
. The amazing new features and light weight design have been largely responsible... convenient their lives have been or how their entertainment experiences have been...Protecting Your iPad Has Never Been Easier Since its release early in 2010
Duplicated Session Variables
;     We don't have any need to create a new session variable because it has been created by the JSP container for you... name. Consider we have declared a session variable true in jsp page <%@ page
What values initialized inside init() in servlet - Java Interview Questions
What values initialized inside init() in servlet  What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once... initialization " . Again interview asked what values will be initialized . what
Converting jsp variable to java variable
Converting jsp variable to java variable  Hi how to convert java script variable to java variable on same jsp page
Pointer a variable
Pointer a variable  hii, Pointer is a variable or not ?   hello,ADS_TO_REPLACE_1 Yes, a pointer is a variable
Passing variable
Passing variable  How to pass variable to HTTP object in HTMl or PHP
Creating a Local Variable in JSP
Creating a Local Variable in JSP      In jsp when we have to create a method or variable we usually declare.... This works like a instance variable.  Now consider a situation where we have
Referance variable - Java Interview Questions
variable and parameter. When the method is called, the parameter slots are initialized...Referance variable  by using which reference variable we declare instance variable as local variable in java   Hi friend,Local variables
Application Variable
Application Variable  I have multiple JSP's that are connected... the necessary data to establish a connection.. In every page I have to call... anyone show a simple sample code of storing the connection data in a variable so
final variable
final variable  Please give some easiest and understanding example program for final variable
environment variable
environment variable  what are the environment variable is need to run j2ee application in eclipse could you explain the details
ModuleNotFoundError: No module named 'variable'
ModuleNotFoundError: No module named 'variable'  Hi, My Python... 'variable' How to remove the ModuleNotFoundError: No module named 'variable' error? Thanks   Hi, In your python environment you have
What is instance variable in Java?
What is instance variable in Java?  Hi, What is instance variable in Java? What is the use of instance variable? Thanks   Hi, In Java programming classes are used as base of Object oriented programming. Any variable
environment variable
environment variable  what is environment variable in java?   Environment variables are used by the Operating System to pass configuration information to applications
Static Variable
Static Variable  What is the basic use of introducing static variable... that a certain object/variable is resident in memory and accessed each time an instance..., it means that the static variable is shared among all instances of the class
how to value of one variable pass in other variable in revetse order
how to value of one variable pass in other variable in revetse order  Like variable a=367 b must have valuev763
creating a global variable with php
creating a global variable with php  Is it possible to create a variable to declare as global in case of database connectivity?   Yes, if you want to have access of that variable anywhere in the program. See the example
Java Final Variable
Java Final Variable  I have some confusion --Final variable has single copy for each object so can we access final variable through class name,or it is necessary to create object for accessing final variable
Dynamic variable in java - Java Interview Questions
Dynamic variable in java  My interview asked what is dynamic variable in java and where we use them.   Hi Friend, The variables that are initialized at run time is called as dynamic variable.You can use it anywhere
Static variable in java
. These variable are initialized first before initializing of any instance...Static variable in java. Static is a keyword in java used to create static methods, variable inside a class and static class. Static variable
how to assign javascript variable value to a jsp variable
how to assign javascript variable value to a jsp variable  how to assign javascript variable value to a jsp variable
How to create variable in TensorFlow?
variable, you have to create the TensorFlow variable to use it with TensorFlow graph. Then tf.variable() method is used to create variable in TensorFlow...How to create variable in TensorFlow?  Hi, How to create variable
define string variable in php
define string variable in php  how to define string variable in PHP
global variable in objective c
global variable in objective c  Declaring global variable in objective c
help regarding variable types and its modifiers
help regarding variable types and its modifiers  static variable is initialized once only and can be used by all objects. i want static in sense... by user. is it possible to declare a variable as counter which will increment each
php variable functions
php variable functions  Setting a variable in a class function, where can I use that variable
static variable in php
static variable in php  How can i call a global variable as a static variable
Instance variable in java
. Access modifier can be given for instance variable. Instance variable have...Instance variable in java In this section you will learn about Instance variable in java. In java all variable must be declared before they are used
JBoss Tools 3 Alpha has been released
, Portal etc. All plugins in the new release have been now shifted to Eclipse... in the Eclipse API. The new features that have been added to this Release are as follows...The first Alpha release of JBoss Tools 3 has been made recently with intials
JSP Create Variable
an array variable of string type where we have defined the days of week... JSP Create Variable          JSP Create Variable is used to create
Flex Variable Scope
Scope of the variable defines the accessibility of the variable across the application. The global variable has global access to the application and local variable is restricted to the block of code only. The variable defined outside
JSP Variable in Javascript
JSP Variable in Javascript          JSP Variable in Javascript helps you to pass jsp variable to javascript. The JavaScript include a function
how to inherit static variable
how to inherit static variable   how to inherit static variable or methods in Java?? Please explain the entire process of inheriting the variable. Thanks in advance
php search variable
php search variable  Search variable in PHP
variable function in php
variable function in php  Can any one tell me how to write a variable function in PHP?   Go through the PHP Variable function tutorial ... PHP Variable Function

Ads